1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gio.FileIF; 26 27 private import gio.AppInfoIF; 28 private import gio.AsyncResultIF; 29 private import gio.Cancellable; 30 private import gio.FileAttributeInfoList; 31 private import gio.FileEnumerator; 32 private import gio.FileIF; 33 private import gio.FileIOStream; 34 private import gio.FileInfo; 35 private import gio.FileInputStream; 36 private import gio.FileMonitor; 37 private import gio.FileOutputStream; 38 private import gio.MountIF; 39 private import gio.MountOperation; 40 private import gio.c.functions; 41 public import gio.c.types; 42 private import glib.Bytes; 43 private import glib.ConstructionException; 44 private import glib.ErrorG; 45 private import glib.GException; 46 private import glib.Str; 47 private import glib.c.functions; 48 private import gobject.ObjectG; 49 50 51 /** 52 * #GFile is a high level abstraction for manipulating files on a 53 * virtual file system. #GFiles are lightweight, immutable objects 54 * that do no I/O upon creation. It is necessary to understand that 55 * #GFile objects do not represent files, merely an identifier for a 56 * file. All file content I/O is implemented as streaming operations 57 * (see #GInputStream and #GOutputStream). 58 * 59 * To construct a #GFile, you can use: 60 * - g_file_new_for_path() if you have a path. 61 * - g_file_new_for_uri() if you have a URI. 62 * - g_file_new_for_commandline_arg() for a command line argument. 63 * - g_file_new_tmp() to create a temporary file from a template. 64 * - g_file_parse_name() from a UTF-8 string gotten from g_file_get_parse_name(). 65 * - g_file_new_build_filename() to create a file from path elements. 66 * 67 * One way to think of a #GFile is as an abstraction of a pathname. For 68 * normal files the system pathname is what is stored internally, but as 69 * #GFiles are extensible it could also be something else that corresponds 70 * to a pathname in a userspace implementation of a filesystem. 71 * 72 * #GFiles make up hierarchies of directories and files that correspond to 73 * the files on a filesystem. You can move through the file system with 74 * #GFile using g_file_get_parent() to get an identifier for the parent 75 * directory, g_file_get_child() to get a child within a directory, 76 * g_file_resolve_relative_path() to resolve a relative path between two 77 * #GFiles. There can be multiple hierarchies, so you may not end up at 78 * the same root if you repeatedly call g_file_get_parent() on two different 79 * files. 80 * 81 * All #GFiles have a basename (get with g_file_get_basename()). These names 82 * are byte strings that are used to identify the file on the filesystem 83 * (relative to its parent directory) and there is no guarantees that they 84 * have any particular charset encoding or even make any sense at all. If 85 * you want to use filenames in a user interface you should use the display 86 * name that you can get by requesting the 87 * %G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME attribute with g_file_query_info(). 88 * This is guaranteed to be in UTF-8 and can be used in a user interface. 89 * But always store the real basename or the #GFile to use to actually 90 * access the file, because there is no way to go from a display name to 91 * the actual name. 92 * 93 * Using #GFile as an identifier has the same weaknesses as using a path 94 * in that there may be multiple aliases for the same file. For instance, 95 * hard or soft links may cause two different #GFiles to refer to the same 96 * file. Other possible causes for aliases are: case insensitive filesystems, 97 * short and long names on FAT/NTFS, or bind mounts in Linux. If you want to 98 * check if two #GFiles point to the same file you can query for the 99 * %G_FILE_ATTRIBUTE_ID_FILE attribute. Note that #GFile does some trivial 100 * canonicalization of pathnames passed in, so that trivial differences in 101 * the path string used at creation (duplicated slashes, slash at end of 102 * path, "." or ".." path segments, etc) does not create different #GFiles. 103 * 104 * Many #GFile operations have both synchronous and asynchronous versions 105 * to suit your application. Asynchronous versions of synchronous functions 106 * simply have _async() appended to their function names. The asynchronous 107 * I/O functions call a #GAsyncReadyCallback which is then used to finalize 108 * the operation, producing a GAsyncResult which is then passed to the 109 * function's matching _finish() operation. 110 * 111 * It is highly recommended to use asynchronous calls when running within a 112 * shared main loop, such as in the main thread of an application. This avoids 113 * I/O operations blocking other sources on the main loop from being dispatched. 114 * Synchronous I/O operations should be performed from worker threads. See the 115 * [introduction to asynchronous programming section][async-programming] for 116 * more. 117 * 118 * Some #GFile operations almost always take a noticeable amount of time, and 119 * so do not have synchronous analogs. Notable cases include: 120 * - g_file_mount_mountable() to mount a mountable file. 121 * - g_file_unmount_mountable_with_operation() to unmount a mountable file. 122 * - g_file_eject_mountable_with_operation() to eject a mountable file. 123 * 124 * ## Entity Tags # {#gfile-etag} 125 * 126 * One notable feature of #GFiles are entity tags, or "etags" for 127 * short. Entity tags are somewhat like a more abstract version of the 128 * traditional mtime, and can be used to quickly determine if the file 129 * has been modified from the version on the file system. See the 130 * HTTP 1.1 131 * [specification](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html) 132 * for HTTP Etag headers, which are a very similar concept. 133 */ 134 public interface FileIF{ 135 /** Get the main Gtk struct */ 136 public GFile* getFileStruct(bool transferOwnership = false); 137 138 /** the main Gtk struct as a void* */ 139 protected void* getStruct(); 140 141 142 /** */ 143 public static GType getType() 144 { 145 return g_file_get_type(); 146 } 147 148 /** 149 * Constructs a #GFile with the given @parse_name (i.e. something 150 * given by g_file_get_parse_name()). This operation never fails, 151 * but the returned object might not support any I/O operation if 152 * the @parse_name cannot be parsed. 153 * 154 * Params: 155 * parseName = a file name or path to be parsed 156 * 157 * Returns: a new #GFile. 158 */ 159 public static FileIF parseName(string parseName) 160 { 161 auto __p = g_file_parse_name(Str.toStringz(parseName)); 162 163 if(__p is null) 164 { 165 return null; 166 } 167 168 return ObjectG.getDObject!(FileIF)(cast(GFile*) __p, true); 169 } 170 171 /** 172 * Gets an output stream for appending data to the file. 173 * If the file doesn't already exist it is created. 174 * 175 * By default files created are generally readable by everyone, 176 * but if you pass %G_FILE_CREATE_PRIVATE in @flags the file 177 * will be made readable only to the current user, to the level that 178 * is supported on the target filesystem. 179 * 180 * If @cancellable is not %NULL, then the operation can be cancelled 181 * by triggering the cancellable object from another thread. If the 182 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 183 * returned. 184 * 185 * Some file systems don't allow all file names, and may return an 186 * %G_IO_ERROR_INVALID_FILENAME error. If the file is a directory the 187 * %G_IO_ERROR_IS_DIRECTORY error will be returned. Other errors are 188 * possible too, and depend on what kind of filesystem the file is on. 189 * 190 * Params: 191 * flags = a set of #GFileCreateFlags 192 * cancellable = optional #GCancellable object, 193 * %NULL to ignore 194 * 195 * Returns: a #GFileOutputStream, or %NULL on error. 196 * Free the returned object with g_object_unref(). 197 * 198 * Throws: GException on failure. 199 */ 200 public FileOutputStream appendTo(GFileCreateFlags flags, Cancellable cancellable); 201 202 /** 203 * Asynchronously opens @file for appending. 204 * 205 * For more details, see g_file_append_to() which is 206 * the synchronous version of this call. 207 * 208 * When the operation is finished, @callback will be called. 209 * You can then call g_file_append_to_finish() to get the result 210 * of the operation. 211 * 212 * Params: 213 * flags = a set of #GFileCreateFlags 214 * ioPriority = the [I/O priority][io-priority] of the request 215 * cancellable = optional #GCancellable object, 216 * %NULL to ignore 217 * callback = a #GAsyncReadyCallback to call 218 * when the request is satisfied 219 * userData = the data to pass to callback function 220 */ 221 public void appendToAsync(GFileCreateFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 222 223 /** 224 * Finishes an asynchronous file append operation started with 225 * g_file_append_to_async(). 226 * 227 * Params: 228 * res = #GAsyncResult 229 * 230 * Returns: a valid #GFileOutputStream 231 * or %NULL on error. 232 * Free the returned object with g_object_unref(). 233 * 234 * Throws: GException on failure. 235 */ 236 public FileOutputStream appendToFinish(AsyncResultIF res); 237 238 /** 239 * Prepares the file attribute query string for copying to @file. 240 * 241 * This function prepares an attribute query string to be 242 * passed to g_file_query_info() to get a list of attributes 243 * normally copied with the file (see g_file_copy_attributes() 244 * for the detailed description). This function is used by the 245 * implementation of g_file_copy_attributes() and is useful 246 * when one needs to query and set the attributes in two 247 * stages (e.g., for recursive move of a directory). 248 * 249 * Params: 250 * flags = a set of #GFileCopyFlags 251 * cancellable = optional #GCancellable object, 252 * %NULL to ignore 253 * 254 * Returns: an attribute query string for g_file_query_info(), 255 * or %NULL if an error occurs. 256 * 257 * Since: 2.68 258 * 259 * Throws: GException on failure. 260 */ 261 public string buildAttributeListForCopy(GFileCopyFlags flags, Cancellable cancellable); 262 263 /** 264 * Copies the file @source to the location specified by @destination. 265 * Can not handle recursive copies of directories. 266 * 267 * If the flag %G_FILE_COPY_OVERWRITE is specified an already 268 * existing @destination file is overwritten. 269 * 270 * If the flag %G_FILE_COPY_NOFOLLOW_SYMLINKS is specified then symlinks 271 * will be copied as symlinks, otherwise the target of the 272 * @source symlink will be copied. 273 * 274 * If the flag %G_FILE_COPY_ALL_METADATA is specified then all the metadata 275 * that is possible to copy is copied, not just the default subset (which, 276 * for instance, does not include the owner, see #GFileInfo). 277 * 278 * If @cancellable is not %NULL, then the operation can be cancelled by 279 * triggering the cancellable object from another thread. If the operation 280 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 281 * 282 * If @progress_callback is not %NULL, then the operation can be monitored 283 * by setting this to a #GFileProgressCallback function. 284 * @progress_callback_data will be passed to this function. It is guaranteed 285 * that this callback will be called after all data has been transferred with 286 * the total number of bytes copied during the operation. 287 * 288 * If the @source file does not exist, then the %G_IO_ERROR_NOT_FOUND error 289 * is returned, independent on the status of the @destination. 290 * 291 * If %G_FILE_COPY_OVERWRITE is not specified and the target exists, then 292 * the error %G_IO_ERROR_EXISTS is returned. 293 * 294 * If trying to overwrite a file over a directory, the %G_IO_ERROR_IS_DIRECTORY 295 * error is returned. If trying to overwrite a directory with a directory the 296 * %G_IO_ERROR_WOULD_MERGE error is returned. 297 * 298 * If the source is a directory and the target does not exist, or 299 * %G_FILE_COPY_OVERWRITE is specified and the target is a file, then the 300 * %G_IO_ERROR_WOULD_RECURSE error is returned. 301 * 302 * If you are interested in copying the #GFile object itself (not the on-disk 303 * file), see g_file_dup(). 304 * 305 * Params: 306 * destination = destination #GFile 307 * flags = set of #GFileCopyFlags 308 * cancellable = optional #GCancellable object, 309 * %NULL to ignore 310 * progressCallback = function to callback with 311 * progress information, or %NULL if progress information is not needed 312 * progressCallbackData = user data to pass to @progress_callback 313 * 314 * Returns: %TRUE on success, %FALSE otherwise. 315 * 316 * Throws: GException on failure. 317 */ 318 public bool copy(FileIF destination, GFileCopyFlags flags, Cancellable cancellable, GFileProgressCallback progressCallback, void* progressCallbackData); 319 320 /** 321 * Copies the file @source to the location specified by @destination 322 * asynchronously. For details of the behaviour, see g_file_copy(). 323 * 324 * If @progress_callback is not %NULL, then that function that will be called 325 * just like in g_file_copy(). The callback will run in the default main context 326 * of the thread calling g_file_copy_async() — the same context as @callback is 327 * run in. 328 * 329 * When the operation is finished, @callback will be called. You can then call 330 * g_file_copy_finish() to get the result of the operation. 331 * 332 * Params: 333 * destination = destination #GFile 334 * flags = set of #GFileCopyFlags 335 * ioPriority = the [I/O priority][io-priority] of the request 336 * cancellable = optional #GCancellable object, 337 * %NULL to ignore 338 * progressCallback = function to callback with progress 339 * information, or %NULL if progress information is not needed 340 * progressCallbackData = user data to pass to @progress_callback 341 * callback = a #GAsyncReadyCallback to call when the request is satisfied 342 * userData = the data to pass to callback function 343 */ 344 public void copyAsync(FileIF destination, GFileCopyFlags flags, int ioPriority, Cancellable cancellable, GFileProgressCallback progressCallback, void* progressCallbackData, GAsyncReadyCallback callback, void* userData); 345 346 /** 347 * Copies the file attributes from @source to @destination. 348 * 349 * Normally only a subset of the file attributes are copied, 350 * those that are copies in a normal file copy operation 351 * (which for instance does not include e.g. owner). However 352 * if %G_FILE_COPY_ALL_METADATA is specified in @flags, then 353 * all the metadata that is possible to copy is copied. This 354 * is useful when implementing move by copy + delete source. 355 * 356 * Params: 357 * destination = a #GFile to copy attributes to 358 * flags = a set of #GFileCopyFlags 359 * cancellable = optional #GCancellable object, 360 * %NULL to ignore 361 * 362 * Returns: %TRUE if the attributes were copied successfully, 363 * %FALSE otherwise. 364 * 365 * Throws: GException on failure. 366 */ 367 public bool copyAttributes(FileIF destination, GFileCopyFlags flags, Cancellable cancellable); 368 369 /** 370 * Finishes copying the file started with g_file_copy_async(). 371 * 372 * Params: 373 * res = a #GAsyncResult 374 * 375 * Returns: a %TRUE on success, %FALSE on error. 376 * 377 * Throws: GException on failure. 378 */ 379 public bool copyFinish(AsyncResultIF res); 380 381 /** 382 * Creates a new file and returns an output stream for writing to it. 383 * The file must not already exist. 384 * 385 * By default files created are generally readable by everyone, 386 * but if you pass %G_FILE_CREATE_PRIVATE in @flags the file 387 * will be made readable only to the current user, to the level 388 * that is supported on the target filesystem. 389 * 390 * If @cancellable is not %NULL, then the operation can be cancelled 391 * by triggering the cancellable object from another thread. If the 392 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 393 * returned. 394 * 395 * If a file or directory with this name already exists the 396 * %G_IO_ERROR_EXISTS error will be returned. Some file systems don't 397 * allow all file names, and may return an %G_IO_ERROR_INVALID_FILENAME 398 * error, and if the name is to long %G_IO_ERROR_FILENAME_TOO_LONG will 399 * be returned. Other errors are possible too, and depend on what kind 400 * of filesystem the file is on. 401 * 402 * Params: 403 * flags = a set of #GFileCreateFlags 404 * cancellable = optional #GCancellable object, 405 * %NULL to ignore 406 * 407 * Returns: a #GFileOutputStream for the newly created 408 * file, or %NULL on error. 409 * Free the returned object with g_object_unref(). 410 * 411 * Throws: GException on failure. 412 */ 413 public FileOutputStream create(GFileCreateFlags flags, Cancellable cancellable); 414 415 /** 416 * Asynchronously creates a new file and returns an output stream 417 * for writing to it. The file must not already exist. 418 * 419 * For more details, see g_file_create() which is 420 * the synchronous version of this call. 421 * 422 * When the operation is finished, @callback will be called. 423 * You can then call g_file_create_finish() to get the result 424 * of the operation. 425 * 426 * Params: 427 * flags = a set of #GFileCreateFlags 428 * ioPriority = the [I/O priority][io-priority] of the request 429 * cancellable = optional #GCancellable object, 430 * %NULL to ignore 431 * callback = a #GAsyncReadyCallback to call 432 * when the request is satisfied 433 * userData = the data to pass to callback function 434 */ 435 public void createAsync(GFileCreateFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 436 437 /** 438 * Finishes an asynchronous file create operation started with 439 * g_file_create_async(). 440 * 441 * Params: 442 * res = a #GAsyncResult 443 * 444 * Returns: a #GFileOutputStream or %NULL on error. 445 * Free the returned object with g_object_unref(). 446 * 447 * Throws: GException on failure. 448 */ 449 public FileOutputStream createFinish(AsyncResultIF res); 450 451 /** 452 * Creates a new file and returns a stream for reading and 453 * writing to it. The file must not already exist. 454 * 455 * By default files created are generally readable by everyone, 456 * but if you pass %G_FILE_CREATE_PRIVATE in @flags the file 457 * will be made readable only to the current user, to the level 458 * that is supported on the target filesystem. 459 * 460 * If @cancellable is not %NULL, then the operation can be cancelled 461 * by triggering the cancellable object from another thread. If the 462 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 463 * returned. 464 * 465 * If a file or directory with this name already exists, the 466 * %G_IO_ERROR_EXISTS error will be returned. Some file systems don't 467 * allow all file names, and may return an %G_IO_ERROR_INVALID_FILENAME 468 * error, and if the name is too long, %G_IO_ERROR_FILENAME_TOO_LONG 469 * will be returned. Other errors are possible too, and depend on what 470 * kind of filesystem the file is on. 471 * 472 * Note that in many non-local file cases read and write streams are 473 * not supported, so make sure you really need to do read and write 474 * streaming, rather than just opening for reading or writing. 475 * 476 * Params: 477 * flags = a set of #GFileCreateFlags 478 * cancellable = optional #GCancellable object, 479 * %NULL to ignore 480 * 481 * Returns: a #GFileIOStream for the newly created 482 * file, or %NULL on error. 483 * Free the returned object with g_object_unref(). 484 * 485 * Since: 2.22 486 * 487 * Throws: GException on failure. 488 */ 489 public FileIOStream createReadwrite(GFileCreateFlags flags, Cancellable cancellable); 490 491 /** 492 * Asynchronously creates a new file and returns a stream 493 * for reading and writing to it. The file must not already exist. 494 * 495 * For more details, see g_file_create_readwrite() which is 496 * the synchronous version of this call. 497 * 498 * When the operation is finished, @callback will be called. 499 * You can then call g_file_create_readwrite_finish() to get 500 * the result of the operation. 501 * 502 * Params: 503 * flags = a set of #GFileCreateFlags 504 * ioPriority = the [I/O priority][io-priority] of the request 505 * cancellable = optional #GCancellable object, 506 * %NULL to ignore 507 * callback = a #GAsyncReadyCallback to call 508 * when the request is satisfied 509 * userData = the data to pass to callback function 510 * 511 * Since: 2.22 512 */ 513 public void createReadwriteAsync(GFileCreateFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 514 515 /** 516 * Finishes an asynchronous file create operation started with 517 * g_file_create_readwrite_async(). 518 * 519 * Params: 520 * res = a #GAsyncResult 521 * 522 * Returns: a #GFileIOStream or %NULL on error. 523 * Free the returned object with g_object_unref(). 524 * 525 * Since: 2.22 526 * 527 * Throws: GException on failure. 528 */ 529 public FileIOStream createReadwriteFinish(AsyncResultIF res); 530 531 alias delet = delete_; 532 /** 533 * Deletes a file. If the @file is a directory, it will only be 534 * deleted if it is empty. This has the same semantics as g_unlink(). 535 * 536 * If @file doesn’t exist, %G_IO_ERROR_NOT_FOUND will be returned. This allows 537 * for deletion to be implemented avoiding 538 * [time-of-check to time-of-use races](https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use): 539 * |[ 540 * g_autoptr(GError) local_error = NULL; 541 * if (!g_file_delete (my_file, my_cancellable, &local_error) && 542 * !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) 543 * { 544 * // deletion failed for some reason other than the file not existing: 545 * // so report the error 546 * g_warning ("Failed to delete %s: %s", 547 * g_file_peek_path (my_file), local_error->message); 548 * } 549 * ]| 550 * 551 * If @cancellable is not %NULL, then the operation can be cancelled by 552 * triggering the cancellable object from another thread. If the operation 553 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 554 * 555 * Params: 556 * cancellable = optional #GCancellable object, 557 * %NULL to ignore 558 * 559 * Returns: %TRUE if the file was deleted. %FALSE otherwise. 560 * 561 * Throws: GException on failure. 562 */ 563 public bool delete_(Cancellable cancellable); 564 565 /** 566 * Asynchronously delete a file. If the @file is a directory, it will 567 * only be deleted if it is empty. This has the same semantics as 568 * g_unlink(). 569 * 570 * Params: 571 * ioPriority = the [I/O priority][io-priority] of the request 572 * cancellable = optional #GCancellable object, 573 * %NULL to ignore 574 * callback = a #GAsyncReadyCallback to call 575 * when the request is satisfied 576 * userData = the data to pass to callback function 577 * 578 * Since: 2.34 579 */ 580 public void deleteAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 581 582 /** 583 * Finishes deleting a file started with g_file_delete_async(). 584 * 585 * Params: 586 * result = a #GAsyncResult 587 * 588 * Returns: %TRUE if the file was deleted. %FALSE otherwise. 589 * 590 * Since: 2.34 591 * 592 * Throws: GException on failure. 593 */ 594 public bool deleteFinish(AsyncResultIF result); 595 596 /** 597 * Duplicates a #GFile handle. This operation does not duplicate 598 * the actual file or directory represented by the #GFile; see 599 * g_file_copy() if attempting to copy a file. 600 * 601 * g_file_dup() is useful when a second handle is needed to the same underlying 602 * file, for use in a separate thread (#GFile is not thread-safe). For use 603 * within the same thread, use g_object_ref() to increment the existing object’s 604 * reference count. 605 * 606 * This call does no blocking I/O. 607 * 608 * Returns: a new #GFile that is a duplicate 609 * of the given #GFile. 610 */ 611 public FileIF dup(); 612 613 /** 614 * Starts an asynchronous eject on a mountable. 615 * When this operation has completed, @callback will be called with 616 * @user_user data, and the operation can be finalized with 617 * g_file_eject_mountable_finish(). 618 * 619 * If @cancellable is not %NULL, then the operation can be cancelled by 620 * triggering the cancellable object from another thread. If the operation 621 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 622 * 623 * Deprecated: Use g_file_eject_mountable_with_operation() instead. 624 * 625 * Params: 626 * flags = flags affecting the operation 627 * cancellable = optional #GCancellable object, 628 * %NULL to ignore 629 * callback = a #GAsyncReadyCallback to call 630 * when the request is satisfied, or %NULL 631 * userData = the data to pass to callback function 632 */ 633 public void ejectMountable(GMountUnmountFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 634 635 /** 636 * Finishes an asynchronous eject operation started by 637 * g_file_eject_mountable(). 638 * 639 * Deprecated: Use g_file_eject_mountable_with_operation_finish() 640 * instead. 641 * 642 * Params: 643 * result = a #GAsyncResult 644 * 645 * Returns: %TRUE if the @file was ejected successfully. 646 * %FALSE otherwise. 647 * 648 * Throws: GException on failure. 649 */ 650 public bool ejectMountableFinish(AsyncResultIF result); 651 652 /** 653 * Starts an asynchronous eject on a mountable. 654 * When this operation has completed, @callback will be called with 655 * @user_user data, and the operation can be finalized with 656 * g_file_eject_mountable_with_operation_finish(). 657 * 658 * If @cancellable is not %NULL, then the operation can be cancelled by 659 * triggering the cancellable object from another thread. If the operation 660 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 661 * 662 * Params: 663 * flags = flags affecting the operation 664 * mountOperation = a #GMountOperation, 665 * or %NULL to avoid user interaction 666 * cancellable = optional #GCancellable object, 667 * %NULL to ignore 668 * callback = a #GAsyncReadyCallback to call 669 * when the request is satisfied, or %NULL 670 * userData = the data to pass to callback function 671 * 672 * Since: 2.22 673 */ 674 public void ejectMountableWithOperation(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 675 676 /** 677 * Finishes an asynchronous eject operation started by 678 * g_file_eject_mountable_with_operation(). 679 * 680 * Params: 681 * result = a #GAsyncResult 682 * 683 * Returns: %TRUE if the @file was ejected successfully. 684 * %FALSE otherwise. 685 * 686 * Since: 2.22 687 * 688 * Throws: GException on failure. 689 */ 690 public bool ejectMountableWithOperationFinish(AsyncResultIF result); 691 692 /** 693 * Gets the requested information about the files in a directory. 694 * The result is a #GFileEnumerator object that will give out 695 * #GFileInfo objects for all the files in the directory. 696 * 697 * The @attributes value is a string that specifies the file 698 * attributes that should be gathered. It is not an error if 699 * it's not possible to read a particular requested attribute 700 * from a file - it just won't be set. @attributes should 701 * be a comma-separated list of attributes or attribute wildcards. 702 * The wildcard "*" means all attributes, and a wildcard like 703 * "standard::*" means all attributes in the standard namespace. 704 * An example attribute query be "standard::*,owner::user". 705 * The standard attributes are available as defines, like 706 * %G_FILE_ATTRIBUTE_STANDARD_NAME. %G_FILE_ATTRIBUTE_STANDARD_NAME should 707 * always be specified if you plan to call g_file_enumerator_get_child() or 708 * g_file_enumerator_iterate() on the returned enumerator. 709 * 710 * If @cancellable is not %NULL, then the operation can be cancelled 711 * by triggering the cancellable object from another thread. If the 712 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 713 * returned. 714 * 715 * If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will 716 * be returned. If the file is not a directory, the %G_IO_ERROR_NOT_DIRECTORY 717 * error will be returned. Other errors are possible too. 718 * 719 * Params: 720 * attributes = an attribute query string 721 * flags = a set of #GFileQueryInfoFlags 722 * cancellable = optional #GCancellable object, 723 * %NULL to ignore 724 * 725 * Returns: A #GFileEnumerator if successful, 726 * %NULL on error. Free the returned object with g_object_unref(). 727 * 728 * Throws: GException on failure. 729 */ 730 public FileEnumerator enumerateChildren(string attributes, GFileQueryInfoFlags flags, Cancellable cancellable); 731 732 /** 733 * Asynchronously gets the requested information about the files 734 * in a directory. The result is a #GFileEnumerator object that will 735 * give out #GFileInfo objects for all the files in the directory. 736 * 737 * For more details, see g_file_enumerate_children() which is 738 * the synchronous version of this call. 739 * 740 * When the operation is finished, @callback will be called. You can 741 * then call g_file_enumerate_children_finish() to get the result of 742 * the operation. 743 * 744 * Params: 745 * attributes = an attribute query string 746 * flags = a set of #GFileQueryInfoFlags 747 * ioPriority = the [I/O priority][io-priority] of the request 748 * cancellable = optional #GCancellable object, 749 * %NULL to ignore 750 * callback = a #GAsyncReadyCallback to call when the 751 * request is satisfied 752 * userData = the data to pass to callback function 753 */ 754 public void enumerateChildrenAsync(string attributes, GFileQueryInfoFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 755 756 /** 757 * Finishes an async enumerate children operation. 758 * See g_file_enumerate_children_async(). 759 * 760 * Params: 761 * res = a #GAsyncResult 762 * 763 * Returns: a #GFileEnumerator or %NULL 764 * if an error occurred. 765 * Free the returned object with g_object_unref(). 766 * 767 * Throws: GException on failure. 768 */ 769 public FileEnumerator enumerateChildrenFinish(AsyncResultIF res); 770 771 /** 772 * Checks if the two given #GFiles refer to the same file. 773 * 774 * Note that two #GFiles that differ can still refer to the same 775 * file on the filesystem due to various forms of filename 776 * aliasing. 777 * 778 * This call does no blocking I/O. 779 * 780 * Params: 781 * file2 = the second #GFile 782 * 783 * Returns: %TRUE if @file1 and @file2 are equal. 784 */ 785 public bool equal(FileIF file2); 786 787 /** 788 * Gets a #GMount for the #GFile. 789 * 790 * #GMount is returned only for user interesting locations, see 791 * #GVolumeMonitor. If the #GFileIface for @file does not have a #mount, 792 * @error will be set to %G_IO_ERROR_NOT_FOUND and %NULL #will be returned. 793 * 794 * If @cancellable is not %NULL, then the operation can be cancelled by 795 * triggering the cancellable object from another thread. If the operation 796 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 797 * 798 * Params: 799 * cancellable = optional #GCancellable object, 800 * %NULL to ignore 801 * 802 * Returns: a #GMount where the @file is located 803 * or %NULL on error. 804 * Free the returned object with g_object_unref(). 805 * 806 * Throws: GException on failure. 807 */ 808 public MountIF findEnclosingMount(Cancellable cancellable); 809 810 /** 811 * Asynchronously gets the mount for the file. 812 * 813 * For more details, see g_file_find_enclosing_mount() which is 814 * the synchronous version of this call. 815 * 816 * When the operation is finished, @callback will be called. 817 * You can then call g_file_find_enclosing_mount_finish() to 818 * get the result of the operation. 819 * 820 * Params: 821 * ioPriority = the [I/O priority][io-priority] of the request 822 * cancellable = optional #GCancellable object, 823 * %NULL to ignore 824 * callback = a #GAsyncReadyCallback to call 825 * when the request is satisfied 826 * userData = the data to pass to callback function 827 */ 828 public void findEnclosingMountAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 829 830 /** 831 * Finishes an asynchronous find mount request. 832 * See g_file_find_enclosing_mount_async(). 833 * 834 * Params: 835 * res = a #GAsyncResult 836 * 837 * Returns: #GMount for given @file or %NULL on error. 838 * Free the returned object with g_object_unref(). 839 * 840 * Throws: GException on failure. 841 */ 842 public MountIF findEnclosingMountFinish(AsyncResultIF res); 843 844 /** 845 * Gets the base name (the last component of the path) for a given #GFile. 846 * 847 * If called for the top level of a system (such as the filesystem root 848 * or a uri like sftp://host/) it will return a single directory separator 849 * (and on Windows, possibly a drive letter). 850 * 851 * The base name is a byte string (not UTF-8). It has no defined encoding 852 * or rules other than it may not contain zero bytes. If you want to use 853 * filenames in a user interface you should use the display name that you 854 * can get by requesting the %G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME 855 * attribute with g_file_query_info(). 856 * 857 * This call does no blocking I/O. 858 * 859 * Returns: string containing the #GFile's 860 * base name, or %NULL if given #GFile is invalid. The returned string 861 * should be freed with g_free() when no longer needed. 862 */ 863 public string getBasename(); 864 865 /** 866 * Gets a child of @file with basename equal to @name. 867 * 868 * Note that the file with that specific name might not exist, but 869 * you can still have a #GFile that points to it. You can use this 870 * for instance to create that file. 871 * 872 * This call does no blocking I/O. 873 * 874 * Params: 875 * name = string containing the child's basename 876 * 877 * Returns: a #GFile to a child specified by @name. 878 * Free the returned object with g_object_unref(). 879 */ 880 public FileIF getChild(string name); 881 882 /** 883 * Gets the child of @file for a given @display_name (i.e. a UTF-8 884 * version of the name). If this function fails, it returns %NULL 885 * and @error will be set. This is very useful when constructing a 886 * #GFile for a new file and the user entered the filename in the 887 * user interface, for instance when you select a directory and 888 * type a filename in the file selector. 889 * 890 * This call does no blocking I/O. 891 * 892 * Params: 893 * displayName = string to a possible child 894 * 895 * Returns: a #GFile to the specified child, or 896 * %NULL if the display name couldn't be converted. 897 * Free the returned object with g_object_unref(). 898 * 899 * Throws: GException on failure. 900 */ 901 public FileIF getChildForDisplayName(string displayName); 902 903 /** 904 * Gets the parent directory for the @file. 905 * If the @file represents the root directory of the 906 * file system, then %NULL will be returned. 907 * 908 * This call does no blocking I/O. 909 * 910 * Returns: a #GFile structure to the 911 * parent of the given #GFile or %NULL if there is no parent. Free 912 * the returned object with g_object_unref(). 913 */ 914 public FileIF getParent(); 915 916 /** 917 * Gets the parse name of the @file. 918 * A parse name is a UTF-8 string that describes the 919 * file such that one can get the #GFile back using 920 * g_file_parse_name(). 921 * 922 * This is generally used to show the #GFile as a nice 923 * full-pathname kind of string in a user interface, 924 * like in a location entry. 925 * 926 * For local files with names that can safely be converted 927 * to UTF-8 the pathname is used, otherwise the IRI is used 928 * (a form of URI that allows UTF-8 characters unescaped). 929 * 930 * This call does no blocking I/O. 931 * 932 * Returns: a string containing the #GFile's parse name. 933 * The returned string should be freed with g_free() 934 * when no longer needed. 935 */ 936 public string getParseName(); 937 938 /** 939 * Gets the local pathname for #GFile, if one exists. If non-%NULL, this is 940 * guaranteed to be an absolute, canonical path. It might contain symlinks. 941 * 942 * This call does no blocking I/O. 943 * 944 * Returns: string containing the #GFile's path, 945 * or %NULL if no such path exists. The returned string should be freed 946 * with g_free() when no longer needed. 947 */ 948 public string getPath(); 949 950 /** 951 * Gets the path for @descendant relative to @parent. 952 * 953 * This call does no blocking I/O. 954 * 955 * Params: 956 * descendant = input #GFile 957 * 958 * Returns: string with the relative path from 959 * @descendant to @parent, or %NULL if @descendant doesn't have @parent as 960 * prefix. The returned string should be freed with g_free() when 961 * no longer needed. 962 */ 963 public string getRelativePath(FileIF descendant); 964 965 /** 966 * Gets the URI for the @file. 967 * 968 * This call does no blocking I/O. 969 * 970 * Returns: a string containing the #GFile's URI. If the #GFile was constructed 971 * with an invalid URI, an invalid URI is returned. 972 * The returned string should be freed with g_free() 973 * when no longer needed. 974 */ 975 public string getUri(); 976 977 /** 978 * Gets the URI scheme for a #GFile. 979 * RFC 3986 decodes the scheme as: 980 * |[ 981 * URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] 982 * ]| 983 * Common schemes include "file", "http", "ftp", etc. 984 * 985 * The scheme can be different from the one used to construct the #GFile, 986 * in that it might be replaced with one that is logically equivalent to the #GFile. 987 * 988 * This call does no blocking I/O. 989 * 990 * Returns: a string containing the URI scheme for the given 991 * #GFile or %NULL if the #GFile was constructed with an invalid URI. The 992 * returned string should be freed with g_free() when no longer needed. 993 */ 994 public string getUriScheme(); 995 996 /** 997 * Checks if @file has a parent, and optionally, if it is @parent. 998 * 999 * If @parent is %NULL then this function returns %TRUE if @file has any 1000 * parent at all. If @parent is non-%NULL then %TRUE is only returned 1001 * if @file is an immediate child of @parent. 1002 * 1003 * Params: 1004 * parent = the parent to check for, or %NULL 1005 * 1006 * Returns: %TRUE if @file is an immediate child of @parent (or any parent in 1007 * the case that @parent is %NULL). 1008 * 1009 * Since: 2.24 1010 */ 1011 public bool hasParent(FileIF parent); 1012 1013 /** 1014 * Checks whether @file has the prefix specified by @prefix. 1015 * 1016 * In other words, if the names of initial elements of @file's 1017 * pathname match @prefix. Only full pathname elements are matched, 1018 * so a path like /foo is not considered a prefix of /foobar, only 1019 * of /foo/bar. 1020 * 1021 * A #GFile is not a prefix of itself. If you want to check for 1022 * equality, use g_file_equal(). 1023 * 1024 * This call does no I/O, as it works purely on names. As such it can 1025 * sometimes return %FALSE even if @file is inside a @prefix (from a 1026 * filesystem point of view), because the prefix of @file is an alias 1027 * of @prefix. 1028 * 1029 * Params: 1030 * prefix = input #GFile 1031 * 1032 * Returns: %TRUE if the @file's parent, grandparent, etc is @prefix, 1033 * %FALSE otherwise. 1034 */ 1035 public bool hasPrefix(FileIF prefix); 1036 1037 /** 1038 * Checks to see if a #GFile has a given URI scheme. 1039 * 1040 * This call does no blocking I/O. 1041 * 1042 * Params: 1043 * uriScheme = a string containing a URI scheme 1044 * 1045 * Returns: %TRUE if #GFile's backend supports the 1046 * given URI scheme, %FALSE if URI scheme is %NULL, 1047 * not supported, or #GFile is invalid. 1048 */ 1049 public bool hasUriScheme(string uriScheme); 1050 1051 /** 1052 * Creates a hash value for a #GFile. 1053 * 1054 * This call does no blocking I/O. 1055 * 1056 * Returns: 0 if @file is not a valid #GFile, otherwise an 1057 * integer that can be used as hash value for the #GFile. 1058 * This function is intended for easily hashing a #GFile to 1059 * add to a #GHashTable or similar data structure. 1060 */ 1061 public uint hash(); 1062 1063 /** 1064 * Checks to see if a file is native to the platform. 1065 * 1066 * A native file is one expressed in the platform-native filename format, 1067 * e.g. "C:\Windows" or "/usr/bin/". This does not mean the file is local, 1068 * as it might be on a locally mounted remote filesystem. 1069 * 1070 * On some systems non-native files may be available using the native 1071 * filesystem via a userspace filesystem (FUSE), in these cases this call 1072 * will return %FALSE, but g_file_get_path() will still return a native path. 1073 * 1074 * This call does no blocking I/O. 1075 * 1076 * Returns: %TRUE if @file is native 1077 */ 1078 public bool isNative(); 1079 1080 /** 1081 * Loads the contents of @file and returns it as #GBytes. 1082 * 1083 * If @file is a resource:// based URI, the resulting bytes will reference the 1084 * embedded resource instead of a copy. Otherwise, this is equivalent to calling 1085 * g_file_load_contents() and g_bytes_new_take(). 1086 * 1087 * For resources, @etag_out will be set to %NULL. 1088 * 1089 * The data contained in the resulting #GBytes is always zero-terminated, but 1090 * this is not included in the #GBytes length. The resulting #GBytes should be 1091 * freed with g_bytes_unref() when no longer in use. 1092 * 1093 * Params: 1094 * cancellable = a #GCancellable or %NULL 1095 * etagOut = a location to place the current 1096 * entity tag for the file, or %NULL if the entity tag is not needed 1097 * 1098 * Returns: a #GBytes or %NULL and @error is set 1099 * 1100 * Since: 2.56 1101 * 1102 * Throws: GException on failure. 1103 */ 1104 public Bytes loadBytes(Cancellable cancellable, out string etagOut); 1105 1106 /** 1107 * Asynchronously loads the contents of @file as #GBytes. 1108 * 1109 * If @file is a resource:// based URI, the resulting bytes will reference the 1110 * embedded resource instead of a copy. Otherwise, this is equivalent to calling 1111 * g_file_load_contents_async() and g_bytes_new_take(). 1112 * 1113 * @callback should call g_file_load_bytes_finish() to get the result of this 1114 * asynchronous operation. 1115 * 1116 * See g_file_load_bytes() for more information. 1117 * 1118 * Params: 1119 * cancellable = a #GCancellable or %NULL 1120 * callback = a #GAsyncReadyCallback to call when the 1121 * request is satisfied 1122 * userData = the data to pass to callback function 1123 * 1124 * Since: 2.56 1125 */ 1126 public void loadBytesAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 1127 1128 /** 1129 * Completes an asynchronous request to g_file_load_bytes_async(). 1130 * 1131 * For resources, @etag_out will be set to %NULL. 1132 * 1133 * The data contained in the resulting #GBytes is always zero-terminated, but 1134 * this is not included in the #GBytes length. The resulting #GBytes should be 1135 * freed with g_bytes_unref() when no longer in use. 1136 * 1137 * See g_file_load_bytes() for more information. 1138 * 1139 * Params: 1140 * result = a #GAsyncResult provided to the callback 1141 * etagOut = a location to place the current 1142 * entity tag for the file, or %NULL if the entity tag is not needed 1143 * 1144 * Returns: a #GBytes or %NULL and @error is set 1145 * 1146 * Since: 2.56 1147 * 1148 * Throws: GException on failure. 1149 */ 1150 public Bytes loadBytesFinish(AsyncResultIF result, out string etagOut); 1151 1152 /** 1153 * Loads the content of the file into memory. The data is always 1154 * zero-terminated, but this is not included in the resultant @length. 1155 * The returned @contents should be freed with g_free() when no longer 1156 * needed. 1157 * 1158 * If @cancellable is not %NULL, then the operation can be cancelled by 1159 * triggering the cancellable object from another thread. If the operation 1160 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1161 * 1162 * Params: 1163 * cancellable = optional #GCancellable object, %NULL to ignore 1164 * contents = a location to place the contents of the file 1165 * etagOut = a location to place the current entity tag for the file, 1166 * or %NULL if the entity tag is not needed 1167 * 1168 * Returns: %TRUE if the @file's contents were successfully loaded. 1169 * %FALSE if there were errors. 1170 * 1171 * Throws: GException on failure. 1172 */ 1173 public bool loadContents(Cancellable cancellable, out string contents, out string etagOut); 1174 1175 /** 1176 * Starts an asynchronous load of the @file's contents. 1177 * 1178 * For more details, see g_file_load_contents() which is 1179 * the synchronous version of this call. 1180 * 1181 * When the load operation has completed, @callback will be called 1182 * with @user data. To finish the operation, call 1183 * g_file_load_contents_finish() with the #GAsyncResult returned by 1184 * the @callback. 1185 * 1186 * If @cancellable is not %NULL, then the operation can be cancelled by 1187 * triggering the cancellable object from another thread. If the operation 1188 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1189 * 1190 * Params: 1191 * cancellable = optional #GCancellable object, %NULL to ignore 1192 * callback = a #GAsyncReadyCallback to call when the request is satisfied 1193 * userData = the data to pass to callback function 1194 */ 1195 public void loadContentsAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 1196 1197 /** 1198 * Finishes an asynchronous load of the @file's contents. 1199 * The contents are placed in @contents, and @length is set to the 1200 * size of the @contents string. The @contents should be freed with 1201 * g_free() when no longer needed. If @etag_out is present, it will be 1202 * set to the new entity tag for the @file. 1203 * 1204 * Params: 1205 * res = a #GAsyncResult 1206 * contents = a location to place the contents of the file 1207 * etagOut = a location to place the current entity tag for the file, 1208 * or %NULL if the entity tag is not needed 1209 * 1210 * Returns: %TRUE if the load was successful. If %FALSE and @error is 1211 * present, it will be set appropriately. 1212 * 1213 * Throws: GException on failure. 1214 */ 1215 public bool loadContentsFinish(AsyncResultIF res, out string contents, out string etagOut); 1216 1217 /** 1218 * Reads the partial contents of a file. A #GFileReadMoreCallback should 1219 * be used to stop reading from the file when appropriate, else this 1220 * function will behave exactly as g_file_load_contents_async(). This 1221 * operation can be finished by g_file_load_partial_contents_finish(). 1222 * 1223 * Users of this function should be aware that @user_data is passed to 1224 * both the @read_more_callback and the @callback. 1225 * 1226 * If @cancellable is not %NULL, then the operation can be cancelled by 1227 * triggering the cancellable object from another thread. If the operation 1228 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1229 * 1230 * Params: 1231 * cancellable = optional #GCancellable object, %NULL to ignore 1232 * readMoreCallback = a 1233 * #GFileReadMoreCallback to receive partial data 1234 * and to specify whether further data should be read 1235 * callback = a #GAsyncReadyCallback to call 1236 * when the request is satisfied 1237 * userData = the data to pass to the callback functions 1238 */ 1239 public void loadPartialContentsAsync(Cancellable cancellable, GFileReadMoreCallback readMoreCallback, GAsyncReadyCallback callback, void* userData); 1240 1241 /** 1242 * Finishes an asynchronous partial load operation that was started 1243 * with g_file_load_partial_contents_async(). The data is always 1244 * zero-terminated, but this is not included in the resultant @length. 1245 * The returned @contents should be freed with g_free() when no longer 1246 * needed. 1247 * 1248 * Params: 1249 * res = a #GAsyncResult 1250 * contents = a location to place the contents of the file 1251 * etagOut = a location to place the current entity tag for the file, 1252 * or %NULL if the entity tag is not needed 1253 * 1254 * Returns: %TRUE if the load was successful. If %FALSE and @error is 1255 * present, it will be set appropriately. 1256 * 1257 * Throws: GException on failure. 1258 */ 1259 public bool loadPartialContentsFinish(AsyncResultIF res, out string contents, out string etagOut); 1260 1261 /** 1262 * Creates a directory. Note that this will only create a child directory 1263 * of the immediate parent directory of the path or URI given by the #GFile. 1264 * To recursively create directories, see g_file_make_directory_with_parents(). 1265 * This function will fail if the parent directory does not exist, setting 1266 * @error to %G_IO_ERROR_NOT_FOUND. If the file system doesn't support 1267 * creating directories, this function will fail, setting @error to 1268 * %G_IO_ERROR_NOT_SUPPORTED. 1269 * 1270 * For a local #GFile the newly created directory will have the default 1271 * (current) ownership and permissions of the current process. 1272 * 1273 * If @cancellable is not %NULL, then the operation can be cancelled by 1274 * triggering the cancellable object from another thread. If the operation 1275 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1276 * 1277 * Params: 1278 * cancellable = optional #GCancellable object, 1279 * %NULL to ignore 1280 * 1281 * Returns: %TRUE on successful creation, %FALSE otherwise. 1282 * 1283 * Throws: GException on failure. 1284 */ 1285 public bool makeDirectory(Cancellable cancellable); 1286 1287 /** 1288 * Asynchronously creates a directory. 1289 * 1290 * Params: 1291 * ioPriority = the [I/O priority][io-priority] of the request 1292 * cancellable = optional #GCancellable object, 1293 * %NULL to ignore 1294 * callback = a #GAsyncReadyCallback to call 1295 * when the request is satisfied 1296 * userData = the data to pass to callback function 1297 * 1298 * Since: 2.38 1299 */ 1300 public void makeDirectoryAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 1301 1302 /** 1303 * Finishes an asynchronous directory creation, started with 1304 * g_file_make_directory_async(). 1305 * 1306 * Params: 1307 * result = a #GAsyncResult 1308 * 1309 * Returns: %TRUE on successful directory creation, %FALSE otherwise. 1310 * 1311 * Since: 2.38 1312 * 1313 * Throws: GException on failure. 1314 */ 1315 public bool makeDirectoryFinish(AsyncResultIF result); 1316 1317 /** 1318 * Creates a directory and any parent directories that may not 1319 * exist similar to 'mkdir -p'. If the file system does not support 1320 * creating directories, this function will fail, setting @error to 1321 * %G_IO_ERROR_NOT_SUPPORTED. If the directory itself already exists, 1322 * this function will fail setting @error to %G_IO_ERROR_EXISTS, unlike 1323 * the similar g_mkdir_with_parents(). 1324 * 1325 * For a local #GFile the newly created directories will have the default 1326 * (current) ownership and permissions of the current process. 1327 * 1328 * If @cancellable is not %NULL, then the operation can be cancelled by 1329 * triggering the cancellable object from another thread. If the operation 1330 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1331 * 1332 * Params: 1333 * cancellable = optional #GCancellable object, 1334 * %NULL to ignore 1335 * 1336 * Returns: %TRUE if all directories have been successfully created, %FALSE 1337 * otherwise. 1338 * 1339 * Since: 2.18 1340 * 1341 * Throws: GException on failure. 1342 */ 1343 public bool makeDirectoryWithParents(Cancellable cancellable); 1344 1345 /** 1346 * Creates a symbolic link named @file which contains the string 1347 * @symlink_value. 1348 * 1349 * If @cancellable is not %NULL, then the operation can be cancelled by 1350 * triggering the cancellable object from another thread. If the operation 1351 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1352 * 1353 * Params: 1354 * symlinkValue = a string with the path for the target 1355 * of the new symlink 1356 * cancellable = optional #GCancellable object, 1357 * %NULL to ignore 1358 * 1359 * Returns: %TRUE on the creation of a new symlink, %FALSE otherwise. 1360 * 1361 * Throws: GException on failure. 1362 */ 1363 public bool makeSymbolicLink(string symlinkValue, Cancellable cancellable); 1364 1365 /** 1366 * Recursively measures the disk usage of @file. 1367 * 1368 * This is essentially an analog of the 'du' command, but it also 1369 * reports the number of directories and non-directory files encountered 1370 * (including things like symbolic links). 1371 * 1372 * By default, errors are only reported against the toplevel file 1373 * itself. Errors found while recursing are silently ignored, unless 1374 * %G_FILE_MEASURE_REPORT_ANY_ERROR is given in @flags. 1375 * 1376 * The returned size, @disk_usage, is in bytes and should be formatted 1377 * with g_format_size() in order to get something reasonable for showing 1378 * in a user interface. 1379 * 1380 * @progress_callback and @progress_data can be given to request 1381 * periodic progress updates while scanning. See the documentation for 1382 * #GFileMeasureProgressCallback for information about when and how the 1383 * callback will be invoked. 1384 * 1385 * Params: 1386 * flags = #GFileMeasureFlags 1387 * cancellable = optional #GCancellable 1388 * progressCallback = a #GFileMeasureProgressCallback 1389 * progressData = user_data for @progress_callback 1390 * diskUsage = the number of bytes of disk space used 1391 * numDirs = the number of directories encountered 1392 * numFiles = the number of non-directories encountered 1393 * 1394 * Returns: %TRUE if successful, with the out parameters set. 1395 * %FALSE otherwise, with @error set. 1396 * 1397 * Since: 2.38 1398 * 1399 * Throws: GException on failure. 1400 */ 1401 public bool measureDiskUsage(GFileMeasureFlags flags, Cancellable cancellable, GFileMeasureProgressCallback progressCallback, void* progressData, out ulong diskUsage, out ulong numDirs, out ulong numFiles); 1402 1403 /** 1404 * Recursively measures the disk usage of @file. 1405 * 1406 * This is the asynchronous version of g_file_measure_disk_usage(). See 1407 * there for more information. 1408 * 1409 * Params: 1410 * flags = #GFileMeasureFlags 1411 * ioPriority = the [I/O priority][io-priority] of the request 1412 * cancellable = optional #GCancellable 1413 * progressCallback = a #GFileMeasureProgressCallback 1414 * progressData = user_data for @progress_callback 1415 * callback = a #GAsyncReadyCallback to call when complete 1416 * userData = the data to pass to callback function 1417 * 1418 * Since: 2.38 1419 */ 1420 public void measureDiskUsageAsync(GFileMeasureFlags flags, int ioPriority, Cancellable cancellable, GFileMeasureProgressCallback progressCallback, void* progressData, GAsyncReadyCallback callback, void* userData); 1421 1422 /** 1423 * Collects the results from an earlier call to 1424 * g_file_measure_disk_usage_async(). See g_file_measure_disk_usage() for 1425 * more information. 1426 * 1427 * Params: 1428 * result = the #GAsyncResult passed to your #GAsyncReadyCallback 1429 * diskUsage = the number of bytes of disk space used 1430 * numDirs = the number of directories encountered 1431 * numFiles = the number of non-directories encountered 1432 * 1433 * Returns: %TRUE if successful, with the out parameters set. 1434 * %FALSE otherwise, with @error set. 1435 * 1436 * Since: 2.38 1437 * 1438 * Throws: GException on failure. 1439 */ 1440 public bool measureDiskUsageFinish(AsyncResultIF result, out ulong diskUsage, out ulong numDirs, out ulong numFiles); 1441 1442 /** 1443 * Obtains a file or directory monitor for the given file, 1444 * depending on the type of the file. 1445 * 1446 * If @cancellable is not %NULL, then the operation can be cancelled by 1447 * triggering the cancellable object from another thread. If the operation 1448 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1449 * 1450 * Params: 1451 * flags = a set of #GFileMonitorFlags 1452 * cancellable = optional #GCancellable object, 1453 * %NULL to ignore 1454 * 1455 * Returns: a #GFileMonitor for the given @file, 1456 * or %NULL on error. 1457 * Free the returned object with g_object_unref(). 1458 * 1459 * Since: 2.18 1460 * 1461 * Throws: GException on failure. 1462 */ 1463 public FileMonitor monitor(GFileMonitorFlags flags, Cancellable cancellable); 1464 1465 /** 1466 * Obtains a directory monitor for the given file. 1467 * This may fail if directory monitoring is not supported. 1468 * 1469 * If @cancellable is not %NULL, then the operation can be cancelled by 1470 * triggering the cancellable object from another thread. If the operation 1471 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1472 * 1473 * It does not make sense for @flags to contain 1474 * %G_FILE_MONITOR_WATCH_HARD_LINKS, since hard links can not be made to 1475 * directories. It is not possible to monitor all the files in a 1476 * directory for changes made via hard links; if you want to do this then 1477 * you must register individual watches with g_file_monitor(). 1478 * 1479 * Params: 1480 * flags = a set of #GFileMonitorFlags 1481 * cancellable = optional #GCancellable object, 1482 * %NULL to ignore 1483 * 1484 * Returns: a #GFileMonitor for the given @file, 1485 * or %NULL on error. 1486 * Free the returned object with g_object_unref(). 1487 * 1488 * Throws: GException on failure. 1489 */ 1490 public FileMonitor monitorDirectory(GFileMonitorFlags flags, Cancellable cancellable); 1491 1492 /** 1493 * Obtains a file monitor for the given file. If no file notification 1494 * mechanism exists, then regular polling of the file is used. 1495 * 1496 * If @cancellable is not %NULL, then the operation can be cancelled by 1497 * triggering the cancellable object from another thread. If the operation 1498 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1499 * 1500 * If @flags contains %G_FILE_MONITOR_WATCH_HARD_LINKS then the monitor 1501 * will also attempt to report changes made to the file via another 1502 * filename (ie, a hard link). Without this flag, you can only rely on 1503 * changes made through the filename contained in @file to be 1504 * reported. Using this flag may result in an increase in resource 1505 * usage, and may not have any effect depending on the #GFileMonitor 1506 * backend and/or filesystem type. 1507 * 1508 * Params: 1509 * flags = a set of #GFileMonitorFlags 1510 * cancellable = optional #GCancellable object, 1511 * %NULL to ignore 1512 * 1513 * Returns: a #GFileMonitor for the given @file, 1514 * or %NULL on error. 1515 * Free the returned object with g_object_unref(). 1516 * 1517 * Throws: GException on failure. 1518 */ 1519 public FileMonitor monitorFile(GFileMonitorFlags flags, Cancellable cancellable); 1520 1521 /** 1522 * Starts a @mount_operation, mounting the volume that contains 1523 * the file @location. 1524 * 1525 * When this operation has completed, @callback will be called with 1526 * @user_user data, and the operation can be finalized with 1527 * g_file_mount_enclosing_volume_finish(). 1528 * 1529 * If @cancellable is not %NULL, then the operation can be cancelled by 1530 * triggering the cancellable object from another thread. If the operation 1531 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1532 * 1533 * Params: 1534 * flags = flags affecting the operation 1535 * mountOperation = a #GMountOperation 1536 * or %NULL to avoid user interaction 1537 * cancellable = optional #GCancellable object, 1538 * %NULL to ignore 1539 * callback = a #GAsyncReadyCallback to call 1540 * when the request is satisfied, or %NULL 1541 * userData = the data to pass to callback function 1542 */ 1543 public void mountEnclosingVolume(GMountMountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 1544 1545 /** 1546 * Finishes a mount operation started by g_file_mount_enclosing_volume(). 1547 * 1548 * Params: 1549 * result = a #GAsyncResult 1550 * 1551 * Returns: %TRUE if successful. If an error has occurred, 1552 * this function will return %FALSE and set @error 1553 * appropriately if present. 1554 * 1555 * Throws: GException on failure. 1556 */ 1557 public bool mountEnclosingVolumeFinish(AsyncResultIF result); 1558 1559 /** 1560 * Mounts a file of type G_FILE_TYPE_MOUNTABLE. 1561 * Using @mount_operation, you can request callbacks when, for instance, 1562 * passwords are needed during authentication. 1563 * 1564 * If @cancellable is not %NULL, then the operation can be cancelled by 1565 * triggering the cancellable object from another thread. If the operation 1566 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1567 * 1568 * When the operation is finished, @callback will be called. 1569 * You can then call g_file_mount_mountable_finish() to get 1570 * the result of the operation. 1571 * 1572 * Params: 1573 * flags = flags affecting the operation 1574 * mountOperation = a #GMountOperation, 1575 * or %NULL to avoid user interaction 1576 * cancellable = optional #GCancellable object, 1577 * %NULL to ignore 1578 * callback = a #GAsyncReadyCallback to call 1579 * when the request is satisfied, or %NULL 1580 * userData = the data to pass to callback function 1581 */ 1582 public void mountMountable(GMountMountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 1583 1584 /** 1585 * Finishes a mount operation. See g_file_mount_mountable() for details. 1586 * 1587 * Finish an asynchronous mount operation that was started 1588 * with g_file_mount_mountable(). 1589 * 1590 * Params: 1591 * result = a #GAsyncResult 1592 * 1593 * Returns: a #GFile or %NULL on error. 1594 * Free the returned object with g_object_unref(). 1595 * 1596 * Throws: GException on failure. 1597 */ 1598 public FileIF mountMountableFinish(AsyncResultIF result); 1599 1600 /** 1601 * Tries to move the file or directory @source to the location specified 1602 * by @destination. If native move operations are supported then this is 1603 * used, otherwise a copy + delete fallback is used. The native 1604 * implementation may support moving directories (for instance on moves 1605 * inside the same filesystem), but the fallback code does not. 1606 * 1607 * If the flag %G_FILE_COPY_OVERWRITE is specified an already 1608 * existing @destination file is overwritten. 1609 * 1610 * If @cancellable is not %NULL, then the operation can be cancelled by 1611 * triggering the cancellable object from another thread. If the operation 1612 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1613 * 1614 * If @progress_callback is not %NULL, then the operation can be monitored 1615 * by setting this to a #GFileProgressCallback function. 1616 * @progress_callback_data will be passed to this function. It is 1617 * guaranteed that this callback will be called after all data has been 1618 * transferred with the total number of bytes copied during the operation. 1619 * 1620 * If the @source file does not exist, then the %G_IO_ERROR_NOT_FOUND 1621 * error is returned, independent on the status of the @destination. 1622 * 1623 * If %G_FILE_COPY_OVERWRITE is not specified and the target exists, 1624 * then the error %G_IO_ERROR_EXISTS is returned. 1625 * 1626 * If trying to overwrite a file over a directory, the %G_IO_ERROR_IS_DIRECTORY 1627 * error is returned. If trying to overwrite a directory with a directory the 1628 * %G_IO_ERROR_WOULD_MERGE error is returned. 1629 * 1630 * If the source is a directory and the target does not exist, or 1631 * %G_FILE_COPY_OVERWRITE is specified and the target is a file, then 1632 * the %G_IO_ERROR_WOULD_RECURSE error may be returned (if the native 1633 * move operation isn't available). 1634 * 1635 * Params: 1636 * destination = #GFile pointing to the destination location 1637 * flags = set of #GFileCopyFlags 1638 * cancellable = optional #GCancellable object, 1639 * %NULL to ignore 1640 * progressCallback = #GFileProgressCallback 1641 * function for updates 1642 * progressCallbackData = gpointer to user data for 1643 * the callback function 1644 * 1645 * Returns: %TRUE on successful move, %FALSE otherwise. 1646 * 1647 * Throws: GException on failure. 1648 */ 1649 public bool move(FileIF destination, GFileCopyFlags flags, Cancellable cancellable, GFileProgressCallback progressCallback, void* progressCallbackData); 1650 1651 /** 1652 * Asynchronously moves a file @source to the location of @destination. For details of the behaviour, see g_file_move(). 1653 * 1654 * If @progress_callback is not %NULL, then that function that will be called 1655 * just like in g_file_move(). The callback will run in the default main context 1656 * of the thread calling g_file_move_async() — the same context as @callback is 1657 * run in. 1658 * 1659 * When the operation is finished, @callback will be called. You can then call 1660 * g_file_move_finish() to get the result of the operation. 1661 * 1662 * Params: 1663 * destination = #GFile pointing to the destination location 1664 * flags = set of #GFileCopyFlags 1665 * ioPriority = the [I/O priority][io-priority] of the request 1666 * cancellable = optional #GCancellable object, 1667 * %NULL to ignore 1668 * progressCallback = #GFileProgressCallback 1669 * function for updates 1670 * progressCallbackData = gpointer to user data for 1671 * the callback function 1672 * callback = a #GAsyncReadyCallback to call 1673 * when the request is satisfied 1674 * userData = the data to pass to callback function 1675 * 1676 * Since: 2.72 1677 */ 1678 public void moveAsync(FileIF destination, GFileCopyFlags flags, int ioPriority, Cancellable cancellable, GFileProgressCallback progressCallback, void* progressCallbackData, GAsyncReadyCallback callback, void* userData); 1679 1680 /** 1681 * Finishes an asynchronous file movement, started with 1682 * g_file_move_async(). 1683 * 1684 * Params: 1685 * result = a #GAsyncResult 1686 * 1687 * Returns: %TRUE on successful file move, %FALSE otherwise. 1688 * 1689 * Since: 2.72 1690 * 1691 * Throws: GException on failure. 1692 */ 1693 public bool moveFinish(AsyncResultIF result); 1694 1695 /** 1696 * Opens an existing file for reading and writing. The result is 1697 * a #GFileIOStream that can be used to read and write the contents 1698 * of the file. 1699 * 1700 * If @cancellable is not %NULL, then the operation can be cancelled 1701 * by triggering the cancellable object from another thread. If the 1702 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 1703 * returned. 1704 * 1705 * If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will 1706 * be returned. If the file is a directory, the %G_IO_ERROR_IS_DIRECTORY 1707 * error will be returned. Other errors are possible too, and depend on 1708 * what kind of filesystem the file is on. Note that in many non-local 1709 * file cases read and write streams are not supported, so make sure you 1710 * really need to do read and write streaming, rather than just opening 1711 * for reading or writing. 1712 * 1713 * Params: 1714 * cancellable = a #GCancellable 1715 * 1716 * Returns: #GFileIOStream or %NULL on error. 1717 * Free the returned object with g_object_unref(). 1718 * 1719 * Since: 2.22 1720 * 1721 * Throws: GException on failure. 1722 */ 1723 public FileIOStream openReadwrite(Cancellable cancellable); 1724 1725 /** 1726 * Asynchronously opens @file for reading and writing. 1727 * 1728 * For more details, see g_file_open_readwrite() which is 1729 * the synchronous version of this call. 1730 * 1731 * When the operation is finished, @callback will be called. 1732 * You can then call g_file_open_readwrite_finish() to get 1733 * the result of the operation. 1734 * 1735 * Params: 1736 * ioPriority = the [I/O priority][io-priority] of the request 1737 * cancellable = optional #GCancellable object, 1738 * %NULL to ignore 1739 * callback = a #GAsyncReadyCallback to call 1740 * when the request is satisfied 1741 * userData = the data to pass to callback function 1742 * 1743 * Since: 2.22 1744 */ 1745 public void openReadwriteAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 1746 1747 /** 1748 * Finishes an asynchronous file read operation started with 1749 * g_file_open_readwrite_async(). 1750 * 1751 * Params: 1752 * res = a #GAsyncResult 1753 * 1754 * Returns: a #GFileIOStream or %NULL on error. 1755 * Free the returned object with g_object_unref(). 1756 * 1757 * Since: 2.22 1758 * 1759 * Throws: GException on failure. 1760 */ 1761 public FileIOStream openReadwriteFinish(AsyncResultIF res); 1762 1763 /** 1764 * Exactly like g_file_get_path(), but caches the result via 1765 * g_object_set_qdata_full(). This is useful for example in C 1766 * applications which mix `g_file_*` APIs with native ones. It 1767 * also avoids an extra duplicated string when possible, so will be 1768 * generally more efficient. 1769 * 1770 * This call does no blocking I/O. 1771 * 1772 * Returns: string containing the #GFile's path, 1773 * or %NULL if no such path exists. The returned string is owned by @file. 1774 * 1775 * Since: 2.56 1776 */ 1777 public string peekPath(); 1778 1779 /** 1780 * Polls a file of type %G_FILE_TYPE_MOUNTABLE. 1781 * 1782 * If @cancellable is not %NULL, then the operation can be cancelled by 1783 * triggering the cancellable object from another thread. If the operation 1784 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1785 * 1786 * When the operation is finished, @callback will be called. 1787 * You can then call g_file_mount_mountable_finish() to get 1788 * the result of the operation. 1789 * 1790 * Params: 1791 * cancellable = optional #GCancellable object, %NULL to ignore 1792 * callback = a #GAsyncReadyCallback to call 1793 * when the request is satisfied, or %NULL 1794 * userData = the data to pass to callback function 1795 * 1796 * Since: 2.22 1797 */ 1798 public void pollMountable(Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 1799 1800 /** 1801 * Finishes a poll operation. See g_file_poll_mountable() for details. 1802 * 1803 * Finish an asynchronous poll operation that was polled 1804 * with g_file_poll_mountable(). 1805 * 1806 * Params: 1807 * result = a #GAsyncResult 1808 * 1809 * Returns: %TRUE if the operation finished successfully. %FALSE 1810 * otherwise. 1811 * 1812 * Since: 2.22 1813 * 1814 * Throws: GException on failure. 1815 */ 1816 public bool pollMountableFinish(AsyncResultIF result); 1817 1818 /** 1819 * Returns the #GAppInfo that is registered as the default 1820 * application to handle the file specified by @file. 1821 * 1822 * If @cancellable is not %NULL, then the operation can be cancelled by 1823 * triggering the cancellable object from another thread. If the operation 1824 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1825 * 1826 * Params: 1827 * cancellable = optional #GCancellable object, %NULL to ignore 1828 * 1829 * Returns: a #GAppInfo if the handle was found, 1830 * %NULL if there were errors. 1831 * When you are done with it, release it with g_object_unref() 1832 * 1833 * Throws: GException on failure. 1834 */ 1835 public AppInfoIF queryDefaultHandler(Cancellable cancellable); 1836 1837 /** 1838 * Async version of g_file_query_default_handler(). 1839 * 1840 * Params: 1841 * ioPriority = the [I/O priority][io-priority] of the request 1842 * cancellable = optional #GCancellable object, %NULL to ignore 1843 * callback = a #GAsyncReadyCallback to call when the request is done 1844 * userData = data to pass to @callback 1845 * 1846 * Since: 2.60 1847 */ 1848 public void queryDefaultHandlerAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 1849 1850 /** 1851 * Finishes a g_file_query_default_handler_async() operation. 1852 * 1853 * Params: 1854 * result = a #GAsyncResult 1855 * 1856 * Returns: a #GAppInfo if the handle was found, 1857 * %NULL if there were errors. 1858 * When you are done with it, release it with g_object_unref() 1859 * 1860 * Since: 2.60 1861 * 1862 * Throws: GException on failure. 1863 */ 1864 public AppInfoIF queryDefaultHandlerFinish(AsyncResultIF result); 1865 1866 /** 1867 * Utility function to check if a particular file exists. This is 1868 * implemented using g_file_query_info() and as such does blocking I/O. 1869 * 1870 * Note that in many cases it is [racy to first check for file existence](https://en.wikipedia.org/wiki/Time_of_check_to_time_of_use) 1871 * and then execute something based on the outcome of that, because the 1872 * file might have been created or removed in between the operations. The 1873 * general approach to handling that is to not check, but just do the 1874 * operation and handle the errors as they come. 1875 * 1876 * As an example of race-free checking, take the case of reading a file, 1877 * and if it doesn't exist, creating it. There are two racy versions: read 1878 * it, and on error create it; and: check if it exists, if not create it. 1879 * These can both result in two processes creating the file (with perhaps 1880 * a partially written file as the result). The correct approach is to 1881 * always try to create the file with g_file_create() which will either 1882 * atomically create the file or fail with a %G_IO_ERROR_EXISTS error. 1883 * 1884 * However, in many cases an existence check is useful in a user interface, 1885 * for instance to make a menu item sensitive/insensitive, so that you don't 1886 * have to fool users that something is possible and then just show an error 1887 * dialog. If you do this, you should make sure to also handle the errors 1888 * that can happen due to races when you execute the operation. 1889 * 1890 * Params: 1891 * cancellable = optional #GCancellable object, 1892 * %NULL to ignore 1893 * 1894 * Returns: %TRUE if the file exists (and can be detected without error), 1895 * %FALSE otherwise (or if cancelled). 1896 */ 1897 public bool queryExists(Cancellable cancellable); 1898 1899 /** 1900 * Utility function to inspect the #GFileType of a file. This is 1901 * implemented using g_file_query_info() and as such does blocking I/O. 1902 * 1903 * The primary use case of this method is to check if a file is 1904 * a regular file, directory, or symlink. 1905 * 1906 * Params: 1907 * flags = a set of #GFileQueryInfoFlags passed to g_file_query_info() 1908 * cancellable = optional #GCancellable object, 1909 * %NULL to ignore 1910 * 1911 * Returns: The #GFileType of the file and %G_FILE_TYPE_UNKNOWN 1912 * if the file does not exist 1913 * 1914 * Since: 2.18 1915 */ 1916 public GFileType queryFileType(GFileQueryInfoFlags flags, Cancellable cancellable); 1917 1918 /** 1919 * Similar to g_file_query_info(), but obtains information 1920 * about the filesystem the @file is on, rather than the file itself. 1921 * For instance the amount of space available and the type of 1922 * the filesystem. 1923 * 1924 * The @attributes value is a string that specifies the attributes 1925 * that should be gathered. It is not an error if it's not possible 1926 * to read a particular requested attribute from a file - it just 1927 * won't be set. @attributes should be a comma-separated list of 1928 * attributes or attribute wildcards. The wildcard "*" means all 1929 * attributes, and a wildcard like "filesystem::*" means all attributes 1930 * in the filesystem namespace. The standard namespace for filesystem 1931 * attributes is "filesystem". Common attributes of interest are 1932 * %G_FILE_ATTRIBUTE_FILESYSTEM_SIZE (the total size of the filesystem 1933 * in bytes), %G_FILE_ATTRIBUTE_FILESYSTEM_FREE (number of bytes available), 1934 * and %G_FILE_ATTRIBUTE_FILESYSTEM_TYPE (type of the filesystem). 1935 * 1936 * If @cancellable is not %NULL, then the operation can be cancelled 1937 * by triggering the cancellable object from another thread. If the 1938 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 1939 * returned. 1940 * 1941 * If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will 1942 * be returned. Other errors are possible too, and depend on what 1943 * kind of filesystem the file is on. 1944 * 1945 * Params: 1946 * attributes = an attribute query string 1947 * cancellable = optional #GCancellable object, 1948 * %NULL to ignore 1949 * 1950 * Returns: a #GFileInfo or %NULL if there was an error. 1951 * Free the returned object with g_object_unref(). 1952 * 1953 * Throws: GException on failure. 1954 */ 1955 public FileInfo queryFilesystemInfo(string attributes, Cancellable cancellable); 1956 1957 /** 1958 * Asynchronously gets the requested information about the filesystem 1959 * that the specified @file is on. The result is a #GFileInfo object 1960 * that contains key-value attributes (such as type or size for the 1961 * file). 1962 * 1963 * For more details, see g_file_query_filesystem_info() which is the 1964 * synchronous version of this call. 1965 * 1966 * When the operation is finished, @callback will be called. You can 1967 * then call g_file_query_info_finish() to get the result of the 1968 * operation. 1969 * 1970 * Params: 1971 * attributes = an attribute query string 1972 * ioPriority = the [I/O priority][io-priority] of the request 1973 * cancellable = optional #GCancellable object, 1974 * %NULL to ignore 1975 * callback = a #GAsyncReadyCallback to call 1976 * when the request is satisfied 1977 * userData = the data to pass to callback function 1978 */ 1979 public void queryFilesystemInfoAsync(string attributes, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 1980 1981 /** 1982 * Finishes an asynchronous filesystem info query. 1983 * See g_file_query_filesystem_info_async(). 1984 * 1985 * Params: 1986 * res = a #GAsyncResult 1987 * 1988 * Returns: #GFileInfo for given @file 1989 * or %NULL on error. 1990 * Free the returned object with g_object_unref(). 1991 * 1992 * Throws: GException on failure. 1993 */ 1994 public FileInfo queryFilesystemInfoFinish(AsyncResultIF res); 1995 1996 /** 1997 * Gets the requested information about specified @file. 1998 * The result is a #GFileInfo object that contains key-value 1999 * attributes (such as the type or size of the file). 2000 * 2001 * The @attributes value is a string that specifies the file 2002 * attributes that should be gathered. It is not an error if 2003 * it's not possible to read a particular requested attribute 2004 * from a file - it just won't be set. @attributes should be a 2005 * comma-separated list of attributes or attribute wildcards. 2006 * The wildcard "*" means all attributes, and a wildcard like 2007 * "standard::*" means all attributes in the standard namespace. 2008 * An example attribute query be "standard::*,owner::user". 2009 * The standard attributes are available as defines, like 2010 * %G_FILE_ATTRIBUTE_STANDARD_NAME. 2011 * 2012 * If @cancellable is not %NULL, then the operation can be cancelled 2013 * by triggering the cancellable object from another thread. If the 2014 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 2015 * returned. 2016 * 2017 * For symlinks, normally the information about the target of the 2018 * symlink is returned, rather than information about the symlink 2019 * itself. However if you pass %G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS 2020 * in @flags the information about the symlink itself will be returned. 2021 * Also, for symlinks that point to non-existing files the information 2022 * about the symlink itself will be returned. 2023 * 2024 * If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will be 2025 * returned. Other errors are possible too, and depend on what kind of 2026 * filesystem the file is on. 2027 * 2028 * Params: 2029 * attributes = an attribute query string 2030 * flags = a set of #GFileQueryInfoFlags 2031 * cancellable = optional #GCancellable object, 2032 * %NULL to ignore 2033 * 2034 * Returns: a #GFileInfo for the given @file, or %NULL 2035 * on error. Free the returned object with g_object_unref(). 2036 * 2037 * Throws: GException on failure. 2038 */ 2039 public FileInfo queryInfo(string attributes, GFileQueryInfoFlags flags, Cancellable cancellable); 2040 2041 /** 2042 * Asynchronously gets the requested information about specified @file. 2043 * The result is a #GFileInfo object that contains key-value attributes 2044 * (such as type or size for the file). 2045 * 2046 * For more details, see g_file_query_info() which is the synchronous 2047 * version of this call. 2048 * 2049 * When the operation is finished, @callback will be called. You can 2050 * then call g_file_query_info_finish() to get the result of the operation. 2051 * 2052 * Params: 2053 * attributes = an attribute query string 2054 * flags = a set of #GFileQueryInfoFlags 2055 * ioPriority = the [I/O priority][io-priority] of the request 2056 * cancellable = optional #GCancellable object, 2057 * %NULL to ignore 2058 * callback = a #GAsyncReadyCallback to call when the 2059 * request is satisfied 2060 * userData = the data to pass to callback function 2061 */ 2062 public void queryInfoAsync(string attributes, GFileQueryInfoFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 2063 2064 /** 2065 * Finishes an asynchronous file info query. 2066 * See g_file_query_info_async(). 2067 * 2068 * Params: 2069 * res = a #GAsyncResult 2070 * 2071 * Returns: #GFileInfo for given @file 2072 * or %NULL on error. Free the returned object with 2073 * g_object_unref(). 2074 * 2075 * Throws: GException on failure. 2076 */ 2077 public FileInfo queryInfoFinish(AsyncResultIF res); 2078 2079 /** 2080 * Obtain the list of settable attributes for the file. 2081 * 2082 * Returns the type and full attribute name of all the attributes 2083 * that can be set on this file. This doesn't mean setting it will 2084 * always succeed though, you might get an access failure, or some 2085 * specific file may not support a specific attribute. 2086 * 2087 * If @cancellable is not %NULL, then the operation can be cancelled by 2088 * triggering the cancellable object from another thread. If the operation 2089 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2090 * 2091 * Params: 2092 * cancellable = optional #GCancellable object, 2093 * %NULL to ignore 2094 * 2095 * Returns: a #GFileAttributeInfoList describing the settable attributes. 2096 * When you are done with it, release it with 2097 * g_file_attribute_info_list_unref() 2098 * 2099 * Throws: GException on failure. 2100 */ 2101 public FileAttributeInfoList querySettableAttributes(Cancellable cancellable); 2102 2103 /** 2104 * Obtain the list of attribute namespaces where new attributes 2105 * can be created by a user. An example of this is extended 2106 * attributes (in the "xattr" namespace). 2107 * 2108 * If @cancellable is not %NULL, then the operation can be cancelled by 2109 * triggering the cancellable object from another thread. If the operation 2110 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2111 * 2112 * Params: 2113 * cancellable = optional #GCancellable object, 2114 * %NULL to ignore 2115 * 2116 * Returns: a #GFileAttributeInfoList describing the writable namespaces. 2117 * When you are done with it, release it with 2118 * g_file_attribute_info_list_unref() 2119 * 2120 * Throws: GException on failure. 2121 */ 2122 public FileAttributeInfoList queryWritableNamespaces(Cancellable cancellable); 2123 2124 /** 2125 * Opens a file for reading. The result is a #GFileInputStream that 2126 * can be used to read the contents of the file. 2127 * 2128 * If @cancellable is not %NULL, then the operation can be cancelled by 2129 * triggering the cancellable object from another thread. If the operation 2130 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2131 * 2132 * If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will be 2133 * returned. If the file is a directory, the %G_IO_ERROR_IS_DIRECTORY 2134 * error will be returned. Other errors are possible too, and depend 2135 * on what kind of filesystem the file is on. 2136 * 2137 * Params: 2138 * cancellable = a #GCancellable 2139 * 2140 * Returns: #GFileInputStream or %NULL on error. 2141 * Free the returned object with g_object_unref(). 2142 * 2143 * Throws: GException on failure. 2144 */ 2145 public FileInputStream read(Cancellable cancellable); 2146 2147 /** 2148 * Asynchronously opens @file for reading. 2149 * 2150 * For more details, see g_file_read() which is 2151 * the synchronous version of this call. 2152 * 2153 * When the operation is finished, @callback will be called. 2154 * You can then call g_file_read_finish() to get the result 2155 * of the operation. 2156 * 2157 * Params: 2158 * ioPriority = the [I/O priority][io-priority] of the request 2159 * cancellable = optional #GCancellable object, 2160 * %NULL to ignore 2161 * callback = a #GAsyncReadyCallback to call 2162 * when the request is satisfied 2163 * userData = the data to pass to callback function 2164 */ 2165 public void readAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 2166 2167 /** 2168 * Finishes an asynchronous file read operation started with 2169 * g_file_read_async(). 2170 * 2171 * Params: 2172 * res = a #GAsyncResult 2173 * 2174 * Returns: a #GFileInputStream or %NULL on error. 2175 * Free the returned object with g_object_unref(). 2176 * 2177 * Throws: GException on failure. 2178 */ 2179 public FileInputStream readFinish(AsyncResultIF res); 2180 2181 /** 2182 * Returns an output stream for overwriting the file, possibly 2183 * creating a backup copy of the file first. If the file doesn't exist, 2184 * it will be created. 2185 * 2186 * This will try to replace the file in the safest way possible so 2187 * that any errors during the writing will not affect an already 2188 * existing copy of the file. For instance, for local files it 2189 * may write to a temporary file and then atomically rename over 2190 * the destination when the stream is closed. 2191 * 2192 * By default files created are generally readable by everyone, 2193 * but if you pass %G_FILE_CREATE_PRIVATE in @flags the file 2194 * will be made readable only to the current user, to the level that 2195 * is supported on the target filesystem. 2196 * 2197 * If @cancellable is not %NULL, then the operation can be cancelled 2198 * by triggering the cancellable object from another thread. If the 2199 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 2200 * returned. 2201 * 2202 * If you pass in a non-%NULL @etag value and @file already exists, then 2203 * this value is compared to the current entity tag of the file, and if 2204 * they differ an %G_IO_ERROR_WRONG_ETAG error is returned. This 2205 * generally means that the file has been changed since you last read 2206 * it. You can get the new etag from g_file_output_stream_get_etag() 2207 * after you've finished writing and closed the #GFileOutputStream. When 2208 * you load a new file you can use g_file_input_stream_query_info() to 2209 * get the etag of the file. 2210 * 2211 * If @make_backup is %TRUE, this function will attempt to make a 2212 * backup of the current file before overwriting it. If this fails 2213 * a %G_IO_ERROR_CANT_CREATE_BACKUP error will be returned. If you 2214 * want to replace anyway, try again with @make_backup set to %FALSE. 2215 * 2216 * If the file is a directory the %G_IO_ERROR_IS_DIRECTORY error will 2217 * be returned, and if the file is some other form of non-regular file 2218 * then a %G_IO_ERROR_NOT_REGULAR_FILE error will be returned. Some 2219 * file systems don't allow all file names, and may return an 2220 * %G_IO_ERROR_INVALID_FILENAME error, and if the name is to long 2221 * %G_IO_ERROR_FILENAME_TOO_LONG will be returned. Other errors are 2222 * possible too, and depend on what kind of filesystem the file is on. 2223 * 2224 * Params: 2225 * etag = an optional [entity tag][gfile-etag] 2226 * for the current #GFile, or #NULL to ignore 2227 * makeBackup = %TRUE if a backup should be created 2228 * flags = a set of #GFileCreateFlags 2229 * cancellable = optional #GCancellable object, 2230 * %NULL to ignore 2231 * 2232 * Returns: a #GFileOutputStream or %NULL on error. 2233 * Free the returned object with g_object_unref(). 2234 * 2235 * Throws: GException on failure. 2236 */ 2237 public FileOutputStream replace(string etag, bool makeBackup, GFileCreateFlags flags, Cancellable cancellable); 2238 2239 /** 2240 * Asynchronously overwrites the file, replacing the contents, 2241 * possibly creating a backup copy of the file first. 2242 * 2243 * For more details, see g_file_replace() which is 2244 * the synchronous version of this call. 2245 * 2246 * When the operation is finished, @callback will be called. 2247 * You can then call g_file_replace_finish() to get the result 2248 * of the operation. 2249 * 2250 * Params: 2251 * etag = an [entity tag][gfile-etag] for the current #GFile, 2252 * or %NULL to ignore 2253 * makeBackup = %TRUE if a backup should be created 2254 * flags = a set of #GFileCreateFlags 2255 * ioPriority = the [I/O priority][io-priority] of the request 2256 * cancellable = optional #GCancellable object, 2257 * %NULL to ignore 2258 * callback = a #GAsyncReadyCallback to call 2259 * when the request is satisfied 2260 * userData = the data to pass to callback function 2261 */ 2262 public void replaceAsync(string etag, bool makeBackup, GFileCreateFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 2263 2264 /** 2265 * Replaces the contents of @file with @contents of @length bytes. 2266 * 2267 * If @etag is specified (not %NULL), any existing file must have that etag, 2268 * or the error %G_IO_ERROR_WRONG_ETAG will be returned. 2269 * 2270 * If @make_backup is %TRUE, this function will attempt to make a backup 2271 * of @file. Internally, it uses g_file_replace(), so will try to replace the 2272 * file contents in the safest way possible. For example, atomic renames are 2273 * used when replacing local files’ contents. 2274 * 2275 * If @cancellable is not %NULL, then the operation can be cancelled by 2276 * triggering the cancellable object from another thread. If the operation 2277 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2278 * 2279 * The returned @new_etag can be used to verify that the file hasn't 2280 * changed the next time it is saved over. 2281 * 2282 * Params: 2283 * contents = a string containing the new contents for @file 2284 * etag = the old [entity-tag][gfile-etag] for the document, 2285 * or %NULL 2286 * makeBackup = %TRUE if a backup should be created 2287 * flags = a set of #GFileCreateFlags 2288 * newEtag = a location to a new [entity tag][gfile-etag] 2289 * for the document. This should be freed with g_free() when no longer 2290 * needed, or %NULL 2291 * cancellable = optional #GCancellable object, %NULL to ignore 2292 * 2293 * Returns: %TRUE if successful. If an error has occurred, this function 2294 * will return %FALSE and set @error appropriately if present. 2295 * 2296 * Throws: GException on failure. 2297 */ 2298 public bool replaceContents(string contents, string etag, bool makeBackup, GFileCreateFlags flags, out string newEtag, Cancellable cancellable); 2299 2300 /** 2301 * Starts an asynchronous replacement of @file with the given 2302 * @contents of @length bytes. @etag will replace the document's 2303 * current entity tag. 2304 * 2305 * When this operation has completed, @callback will be called with 2306 * @user_user data, and the operation can be finalized with 2307 * g_file_replace_contents_finish(). 2308 * 2309 * If @cancellable is not %NULL, then the operation can be cancelled by 2310 * triggering the cancellable object from another thread. If the operation 2311 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2312 * 2313 * If @make_backup is %TRUE, this function will attempt to 2314 * make a backup of @file. 2315 * 2316 * Note that no copy of @contents will be made, so it must stay valid 2317 * until @callback is called. See g_file_replace_contents_bytes_async() 2318 * for a #GBytes version that will automatically hold a reference to the 2319 * contents (without copying) for the duration of the call. 2320 * 2321 * Params: 2322 * contents = string of contents to replace the file with 2323 * etag = a new [entity tag][gfile-etag] for the @file, or %NULL 2324 * makeBackup = %TRUE if a backup should be created 2325 * flags = a set of #GFileCreateFlags 2326 * cancellable = optional #GCancellable object, %NULL to ignore 2327 * callback = a #GAsyncReadyCallback to call when the request is satisfied 2328 * userData = the data to pass to callback function 2329 */ 2330 public void replaceContentsAsync(string contents, string etag, bool makeBackup, GFileCreateFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 2331 2332 /** 2333 * Same as g_file_replace_contents_async() but takes a #GBytes input instead. 2334 * This function will keep a ref on @contents until the operation is done. 2335 * Unlike g_file_replace_contents_async() this allows forgetting about the 2336 * content without waiting for the callback. 2337 * 2338 * When this operation has completed, @callback will be called with 2339 * @user_user data, and the operation can be finalized with 2340 * g_file_replace_contents_finish(). 2341 * 2342 * Params: 2343 * contents = a #GBytes 2344 * etag = a new [entity tag][gfile-etag] for the @file, or %NULL 2345 * makeBackup = %TRUE if a backup should be created 2346 * flags = a set of #GFileCreateFlags 2347 * cancellable = optional #GCancellable object, %NULL to ignore 2348 * callback = a #GAsyncReadyCallback to call when the request is satisfied 2349 * userData = the data to pass to callback function 2350 * 2351 * Since: 2.40 2352 */ 2353 public void replaceContentsBytesAsync(Bytes contents, string etag, bool makeBackup, GFileCreateFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 2354 2355 /** 2356 * Finishes an asynchronous replace of the given @file. See 2357 * g_file_replace_contents_async(). Sets @new_etag to the new entity 2358 * tag for the document, if present. 2359 * 2360 * Params: 2361 * res = a #GAsyncResult 2362 * newEtag = a location of a new [entity tag][gfile-etag] 2363 * for the document. This should be freed with g_free() when it is no 2364 * longer needed, or %NULL 2365 * 2366 * Returns: %TRUE on success, %FALSE on failure. 2367 * 2368 * Throws: GException on failure. 2369 */ 2370 public bool replaceContentsFinish(AsyncResultIF res, out string newEtag); 2371 2372 /** 2373 * Finishes an asynchronous file replace operation started with 2374 * g_file_replace_async(). 2375 * 2376 * Params: 2377 * res = a #GAsyncResult 2378 * 2379 * Returns: a #GFileOutputStream, or %NULL on error. 2380 * Free the returned object with g_object_unref(). 2381 * 2382 * Throws: GException on failure. 2383 */ 2384 public FileOutputStream replaceFinish(AsyncResultIF res); 2385 2386 /** 2387 * Returns an output stream for overwriting the file in readwrite mode, 2388 * possibly creating a backup copy of the file first. If the file doesn't 2389 * exist, it will be created. 2390 * 2391 * For details about the behaviour, see g_file_replace() which does the 2392 * same thing but returns an output stream only. 2393 * 2394 * Note that in many non-local file cases read and write streams are not 2395 * supported, so make sure you really need to do read and write streaming, 2396 * rather than just opening for reading or writing. 2397 * 2398 * Params: 2399 * etag = an optional [entity tag][gfile-etag] 2400 * for the current #GFile, or #NULL to ignore 2401 * makeBackup = %TRUE if a backup should be created 2402 * flags = a set of #GFileCreateFlags 2403 * cancellable = optional #GCancellable object, 2404 * %NULL to ignore 2405 * 2406 * Returns: a #GFileIOStream or %NULL on error. 2407 * Free the returned object with g_object_unref(). 2408 * 2409 * Since: 2.22 2410 * 2411 * Throws: GException on failure. 2412 */ 2413 public FileIOStream replaceReadwrite(string etag, bool makeBackup, GFileCreateFlags flags, Cancellable cancellable); 2414 2415 /** 2416 * Asynchronously overwrites the file in read-write mode, 2417 * replacing the contents, possibly creating a backup copy 2418 * of the file first. 2419 * 2420 * For more details, see g_file_replace_readwrite() which is 2421 * the synchronous version of this call. 2422 * 2423 * When the operation is finished, @callback will be called. 2424 * You can then call g_file_replace_readwrite_finish() to get 2425 * the result of the operation. 2426 * 2427 * Params: 2428 * etag = an [entity tag][gfile-etag] for the current #GFile, 2429 * or %NULL to ignore 2430 * makeBackup = %TRUE if a backup should be created 2431 * flags = a set of #GFileCreateFlags 2432 * ioPriority = the [I/O priority][io-priority] of the request 2433 * cancellable = optional #GCancellable object, 2434 * %NULL to ignore 2435 * callback = a #GAsyncReadyCallback to call 2436 * when the request is satisfied 2437 * userData = the data to pass to callback function 2438 * 2439 * Since: 2.22 2440 */ 2441 public void replaceReadwriteAsync(string etag, bool makeBackup, GFileCreateFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 2442 2443 /** 2444 * Finishes an asynchronous file replace operation started with 2445 * g_file_replace_readwrite_async(). 2446 * 2447 * Params: 2448 * res = a #GAsyncResult 2449 * 2450 * Returns: a #GFileIOStream, or %NULL on error. 2451 * Free the returned object with g_object_unref(). 2452 * 2453 * Since: 2.22 2454 * 2455 * Throws: GException on failure. 2456 */ 2457 public FileIOStream replaceReadwriteFinish(AsyncResultIF res); 2458 2459 /** 2460 * Resolves a relative path for @file to an absolute path. 2461 * 2462 * This call does no blocking I/O. 2463 * 2464 * If the @relative_path is an absolute path name, the resolution 2465 * is done absolutely (without taking @file path as base). 2466 * 2467 * Params: 2468 * relativePath = a given relative path string 2469 * 2470 * Returns: a #GFile for the resolved path. 2471 */ 2472 public FileIF resolveRelativePath(string relativePath); 2473 2474 /** 2475 * Sets an attribute in the file with attribute name @attribute to @value_p. 2476 * 2477 * Some attributes can be unset by setting @type to 2478 * %G_FILE_ATTRIBUTE_TYPE_INVALID and @value_p to %NULL. 2479 * 2480 * If @cancellable is not %NULL, then the operation can be cancelled by 2481 * triggering the cancellable object from another thread. If the operation 2482 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2483 * 2484 * Params: 2485 * attribute = a string containing the attribute's name 2486 * type = The type of the attribute 2487 * valueP = a pointer to the value (or the pointer 2488 * itself if the type is a pointer type) 2489 * flags = a set of #GFileQueryInfoFlags 2490 * cancellable = optional #GCancellable object, 2491 * %NULL to ignore 2492 * 2493 * Returns: %TRUE if the attribute was set, %FALSE otherwise. 2494 * 2495 * Throws: GException on failure. 2496 */ 2497 public bool setAttribute(string attribute, GFileAttributeType type, void* valueP, GFileQueryInfoFlags flags, Cancellable cancellable); 2498 2499 /** 2500 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_BYTE_STRING to @value. 2501 * If @attribute is of a different type, this operation will fail, 2502 * returning %FALSE. 2503 * 2504 * If @cancellable is not %NULL, then the operation can be cancelled by 2505 * triggering the cancellable object from another thread. If the operation 2506 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2507 * 2508 * Params: 2509 * attribute = a string containing the attribute's name 2510 * value = a string containing the attribute's new value 2511 * flags = a #GFileQueryInfoFlags 2512 * cancellable = optional #GCancellable object, 2513 * %NULL to ignore 2514 * 2515 * Returns: %TRUE if the @attribute was successfully set to @value 2516 * in the @file, %FALSE otherwise. 2517 * 2518 * Throws: GException on failure. 2519 */ 2520 public bool setAttributeByteString(string attribute, string value, GFileQueryInfoFlags flags, Cancellable cancellable); 2521 2522 /** 2523 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_INT32 to @value. 2524 * If @attribute is of a different type, this operation will fail. 2525 * 2526 * If @cancellable is not %NULL, then the operation can be cancelled by 2527 * triggering the cancellable object from another thread. If the operation 2528 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2529 * 2530 * Params: 2531 * attribute = a string containing the attribute's name 2532 * value = a #gint32 containing the attribute's new value 2533 * flags = a #GFileQueryInfoFlags 2534 * cancellable = optional #GCancellable object, 2535 * %NULL to ignore 2536 * 2537 * Returns: %TRUE if the @attribute was successfully set to @value 2538 * in the @file, %FALSE otherwise. 2539 * 2540 * Throws: GException on failure. 2541 */ 2542 public bool setAttributeInt32(string attribute, int value, GFileQueryInfoFlags flags, Cancellable cancellable); 2543 2544 /** 2545 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_INT64 to @value. 2546 * If @attribute is of a different type, this operation will fail. 2547 * 2548 * If @cancellable is not %NULL, then the operation can be cancelled by 2549 * triggering the cancellable object from another thread. If the operation 2550 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2551 * 2552 * Params: 2553 * attribute = a string containing the attribute's name 2554 * value = a #guint64 containing the attribute's new value 2555 * flags = a #GFileQueryInfoFlags 2556 * cancellable = optional #GCancellable object, 2557 * %NULL to ignore 2558 * 2559 * Returns: %TRUE if the @attribute was successfully set, %FALSE otherwise. 2560 * 2561 * Throws: GException on failure. 2562 */ 2563 public bool setAttributeInt64(string attribute, long value, GFileQueryInfoFlags flags, Cancellable cancellable); 2564 2565 /** 2566 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_STRING to @value. 2567 * If @attribute is of a different type, this operation will fail. 2568 * 2569 * If @cancellable is not %NULL, then the operation can be cancelled by 2570 * triggering the cancellable object from another thread. If the operation 2571 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2572 * 2573 * Params: 2574 * attribute = a string containing the attribute's name 2575 * value = a string containing the attribute's value 2576 * flags = #GFileQueryInfoFlags 2577 * cancellable = optional #GCancellable object, 2578 * %NULL to ignore 2579 * 2580 * Returns: %TRUE if the @attribute was successfully set, %FALSE otherwise. 2581 * 2582 * Throws: GException on failure. 2583 */ 2584 public bool setAttributeString(string attribute, string value, GFileQueryInfoFlags flags, Cancellable cancellable); 2585 2586 /** 2587 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_UINT32 to @value. 2588 * If @attribute is of a different type, this operation will fail. 2589 * 2590 * If @cancellable is not %NULL, then the operation can be cancelled by 2591 * triggering the cancellable object from another thread. If the operation 2592 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2593 * 2594 * Params: 2595 * attribute = a string containing the attribute's name 2596 * value = a #guint32 containing the attribute's new value 2597 * flags = a #GFileQueryInfoFlags 2598 * cancellable = optional #GCancellable object, 2599 * %NULL to ignore 2600 * 2601 * Returns: %TRUE if the @attribute was successfully set to @value 2602 * in the @file, %FALSE otherwise. 2603 * 2604 * Throws: GException on failure. 2605 */ 2606 public bool setAttributeUint32(string attribute, uint value, GFileQueryInfoFlags flags, Cancellable cancellable); 2607 2608 /** 2609 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_UINT64 to @value. 2610 * If @attribute is of a different type, this operation will fail. 2611 * 2612 * If @cancellable is not %NULL, then the operation can be cancelled by 2613 * triggering the cancellable object from another thread. If the operation 2614 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2615 * 2616 * Params: 2617 * attribute = a string containing the attribute's name 2618 * value = a #guint64 containing the attribute's new value 2619 * flags = a #GFileQueryInfoFlags 2620 * cancellable = optional #GCancellable object, 2621 * %NULL to ignore 2622 * 2623 * Returns: %TRUE if the @attribute was successfully set to @value 2624 * in the @file, %FALSE otherwise. 2625 * 2626 * Throws: GException on failure. 2627 */ 2628 public bool setAttributeUint64(string attribute, ulong value, GFileQueryInfoFlags flags, Cancellable cancellable); 2629 2630 /** 2631 * Asynchronously sets the attributes of @file with @info. 2632 * 2633 * For more details, see g_file_set_attributes_from_info(), 2634 * which is the synchronous version of this call. 2635 * 2636 * When the operation is finished, @callback will be called. 2637 * You can then call g_file_set_attributes_finish() to get 2638 * the result of the operation. 2639 * 2640 * Params: 2641 * info = a #GFileInfo 2642 * flags = a #GFileQueryInfoFlags 2643 * ioPriority = the [I/O priority][io-priority] of the request 2644 * cancellable = optional #GCancellable object, 2645 * %NULL to ignore 2646 * callback = a #GAsyncReadyCallback 2647 * userData = a #gpointer 2648 */ 2649 public void setAttributesAsync(FileInfo info, GFileQueryInfoFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 2650 2651 /** 2652 * Finishes setting an attribute started in g_file_set_attributes_async(). 2653 * 2654 * Params: 2655 * result = a #GAsyncResult 2656 * info = a #GFileInfo 2657 * 2658 * Returns: %TRUE if the attributes were set correctly, %FALSE otherwise. 2659 * 2660 * Throws: GException on failure. 2661 */ 2662 public bool setAttributesFinish(AsyncResultIF result, out FileInfo info); 2663 2664 /** 2665 * Tries to set all attributes in the #GFileInfo on the target 2666 * values, not stopping on the first error. 2667 * 2668 * If there is any error during this operation then @error will 2669 * be set to the first error. Error on particular fields are flagged 2670 * by setting the "status" field in the attribute value to 2671 * %G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING, which means you can 2672 * also detect further errors. 2673 * 2674 * If @cancellable is not %NULL, then the operation can be cancelled by 2675 * triggering the cancellable object from another thread. If the operation 2676 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2677 * 2678 * Params: 2679 * info = a #GFileInfo 2680 * flags = #GFileQueryInfoFlags 2681 * cancellable = optional #GCancellable object, 2682 * %NULL to ignore 2683 * 2684 * Returns: %FALSE if there was any error, %TRUE otherwise. 2685 * 2686 * Throws: GException on failure. 2687 */ 2688 public bool setAttributesFromInfo(FileInfo info, GFileQueryInfoFlags flags, Cancellable cancellable); 2689 2690 /** 2691 * Renames @file to the specified display name. 2692 * 2693 * The display name is converted from UTF-8 to the correct encoding 2694 * for the target filesystem if possible and the @file is renamed to this. 2695 * 2696 * If you want to implement a rename operation in the user interface the 2697 * edit name (%G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME) should be used as the 2698 * initial value in the rename widget, and then the result after editing 2699 * should be passed to g_file_set_display_name(). 2700 * 2701 * On success the resulting converted filename is returned. 2702 * 2703 * If @cancellable is not %NULL, then the operation can be cancelled by 2704 * triggering the cancellable object from another thread. If the operation 2705 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2706 * 2707 * Params: 2708 * displayName = a string 2709 * cancellable = optional #GCancellable object, 2710 * %NULL to ignore 2711 * 2712 * Returns: a #GFile specifying what @file was renamed to, 2713 * or %NULL if there was an error. 2714 * Free the returned object with g_object_unref(). 2715 * 2716 * Throws: GException on failure. 2717 */ 2718 public FileIF setDisplayName(string displayName, Cancellable cancellable); 2719 2720 /** 2721 * Asynchronously sets the display name for a given #GFile. 2722 * 2723 * For more details, see g_file_set_display_name() which is 2724 * the synchronous version of this call. 2725 * 2726 * When the operation is finished, @callback will be called. 2727 * You can then call g_file_set_display_name_finish() to get 2728 * the result of the operation. 2729 * 2730 * Params: 2731 * displayName = a string 2732 * ioPriority = the [I/O priority][io-priority] of the request 2733 * cancellable = optional #GCancellable object, 2734 * %NULL to ignore 2735 * callback = a #GAsyncReadyCallback to call 2736 * when the request is satisfied 2737 * userData = the data to pass to callback function 2738 */ 2739 public void setDisplayNameAsync(string displayName, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 2740 2741 /** 2742 * Finishes setting a display name started with 2743 * g_file_set_display_name_async(). 2744 * 2745 * Params: 2746 * res = a #GAsyncResult 2747 * 2748 * Returns: a #GFile or %NULL on error. 2749 * Free the returned object with g_object_unref(). 2750 * 2751 * Throws: GException on failure. 2752 */ 2753 public FileIF setDisplayNameFinish(AsyncResultIF res); 2754 2755 /** 2756 * Starts a file of type %G_FILE_TYPE_MOUNTABLE. 2757 * Using @start_operation, you can request callbacks when, for instance, 2758 * passwords are needed during authentication. 2759 * 2760 * If @cancellable is not %NULL, then the operation can be cancelled by 2761 * triggering the cancellable object from another thread. If the operation 2762 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2763 * 2764 * When the operation is finished, @callback will be called. 2765 * You can then call g_file_mount_mountable_finish() to get 2766 * the result of the operation. 2767 * 2768 * Params: 2769 * flags = flags affecting the operation 2770 * startOperation = a #GMountOperation, or %NULL to avoid user interaction 2771 * cancellable = optional #GCancellable object, %NULL to ignore 2772 * callback = a #GAsyncReadyCallback to call when the request is satisfied, or %NULL 2773 * userData = the data to pass to callback function 2774 * 2775 * Since: 2.22 2776 */ 2777 public void startMountable(GDriveStartFlags flags, MountOperation startOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 2778 2779 /** 2780 * Finishes a start operation. See g_file_start_mountable() for details. 2781 * 2782 * Finish an asynchronous start operation that was started 2783 * with g_file_start_mountable(). 2784 * 2785 * Params: 2786 * result = a #GAsyncResult 2787 * 2788 * Returns: %TRUE if the operation finished successfully. %FALSE 2789 * otherwise. 2790 * 2791 * Since: 2.22 2792 * 2793 * Throws: GException on failure. 2794 */ 2795 public bool startMountableFinish(AsyncResultIF result); 2796 2797 /** 2798 * Stops a file of type %G_FILE_TYPE_MOUNTABLE. 2799 * 2800 * If @cancellable is not %NULL, then the operation can be cancelled by 2801 * triggering the cancellable object from another thread. If the operation 2802 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2803 * 2804 * When the operation is finished, @callback will be called. 2805 * You can then call g_file_stop_mountable_finish() to get 2806 * the result of the operation. 2807 * 2808 * Params: 2809 * flags = flags affecting the operation 2810 * mountOperation = a #GMountOperation, 2811 * or %NULL to avoid user interaction. 2812 * cancellable = optional #GCancellable object, 2813 * %NULL to ignore 2814 * callback = a #GAsyncReadyCallback to call 2815 * when the request is satisfied, or %NULL 2816 * userData = the data to pass to callback function 2817 * 2818 * Since: 2.22 2819 */ 2820 public void stopMountable(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 2821 2822 /** 2823 * Finishes a stop operation, see g_file_stop_mountable() for details. 2824 * 2825 * Finish an asynchronous stop operation that was started 2826 * with g_file_stop_mountable(). 2827 * 2828 * Params: 2829 * result = a #GAsyncResult 2830 * 2831 * Returns: %TRUE if the operation finished successfully. 2832 * %FALSE otherwise. 2833 * 2834 * Since: 2.22 2835 * 2836 * Throws: GException on failure. 2837 */ 2838 public bool stopMountableFinish(AsyncResultIF result); 2839 2840 /** 2841 * Checks if @file supports 2842 * [thread-default contexts][g-main-context-push-thread-default-context]. 2843 * If this returns %FALSE, you cannot perform asynchronous operations on 2844 * @file in a thread that has a thread-default context. 2845 * 2846 * Returns: Whether or not @file supports thread-default contexts. 2847 * 2848 * Since: 2.22 2849 */ 2850 public bool supportsThreadContexts(); 2851 2852 /** 2853 * Sends @file to the "Trashcan", if possible. This is similar to 2854 * deleting it, but the user can recover it before emptying the trashcan. 2855 * Not all file systems support trashing, so this call can return the 2856 * %G_IO_ERROR_NOT_SUPPORTED error. Since GLib 2.66, the `x-gvfs-notrash` unix 2857 * mount option can be used to disable g_file_trash() support for certain 2858 * mounts, the %G_IO_ERROR_NOT_SUPPORTED error will be returned in that case. 2859 * 2860 * If @cancellable is not %NULL, then the operation can be cancelled by 2861 * triggering the cancellable object from another thread. If the operation 2862 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2863 * 2864 * Params: 2865 * cancellable = optional #GCancellable object, 2866 * %NULL to ignore 2867 * 2868 * Returns: %TRUE on successful trash, %FALSE otherwise. 2869 * 2870 * Throws: GException on failure. 2871 */ 2872 public bool trash(Cancellable cancellable); 2873 2874 /** 2875 * Asynchronously sends @file to the Trash location, if possible. 2876 * 2877 * Params: 2878 * ioPriority = the [I/O priority][io-priority] of the request 2879 * cancellable = optional #GCancellable object, 2880 * %NULL to ignore 2881 * callback = a #GAsyncReadyCallback to call 2882 * when the request is satisfied 2883 * userData = the data to pass to callback function 2884 * 2885 * Since: 2.38 2886 */ 2887 public void trashAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 2888 2889 /** 2890 * Finishes an asynchronous file trashing operation, started with 2891 * g_file_trash_async(). 2892 * 2893 * Params: 2894 * result = a #GAsyncResult 2895 * 2896 * Returns: %TRUE on successful trash, %FALSE otherwise. 2897 * 2898 * Since: 2.38 2899 * 2900 * Throws: GException on failure. 2901 */ 2902 public bool trashFinish(AsyncResultIF result); 2903 2904 /** 2905 * Unmounts a file of type G_FILE_TYPE_MOUNTABLE. 2906 * 2907 * If @cancellable is not %NULL, then the operation can be cancelled by 2908 * triggering the cancellable object from another thread. If the operation 2909 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2910 * 2911 * When the operation is finished, @callback will be called. 2912 * You can then call g_file_unmount_mountable_finish() to get 2913 * the result of the operation. 2914 * 2915 * Deprecated: Use g_file_unmount_mountable_with_operation() instead. 2916 * 2917 * Params: 2918 * flags = flags affecting the operation 2919 * cancellable = optional #GCancellable object, 2920 * %NULL to ignore 2921 * callback = a #GAsyncReadyCallback to call 2922 * when the request is satisfied, or %NULL 2923 * userData = the data to pass to callback function 2924 */ 2925 public void unmountMountable(GMountUnmountFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 2926 2927 /** 2928 * Finishes an unmount operation, see g_file_unmount_mountable() for details. 2929 * 2930 * Finish an asynchronous unmount operation that was started 2931 * with g_file_unmount_mountable(). 2932 * 2933 * Deprecated: Use g_file_unmount_mountable_with_operation_finish() 2934 * instead. 2935 * 2936 * Params: 2937 * result = a #GAsyncResult 2938 * 2939 * Returns: %TRUE if the operation finished successfully. 2940 * %FALSE otherwise. 2941 * 2942 * Throws: GException on failure. 2943 */ 2944 public bool unmountMountableFinish(AsyncResultIF result); 2945 2946 /** 2947 * Unmounts a file of type %G_FILE_TYPE_MOUNTABLE. 2948 * 2949 * If @cancellable is not %NULL, then the operation can be cancelled by 2950 * triggering the cancellable object from another thread. If the operation 2951 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2952 * 2953 * When the operation is finished, @callback will be called. 2954 * You can then call g_file_unmount_mountable_finish() to get 2955 * the result of the operation. 2956 * 2957 * Params: 2958 * flags = flags affecting the operation 2959 * mountOperation = a #GMountOperation, 2960 * or %NULL to avoid user interaction 2961 * cancellable = optional #GCancellable object, 2962 * %NULL to ignore 2963 * callback = a #GAsyncReadyCallback to call 2964 * when the request is satisfied, or %NULL 2965 * userData = the data to pass to callback function 2966 * 2967 * Since: 2.22 2968 */ 2969 public void unmountMountableWithOperation(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData); 2970 2971 /** 2972 * Finishes an unmount operation, 2973 * see g_file_unmount_mountable_with_operation() for details. 2974 * 2975 * Finish an asynchronous unmount operation that was started 2976 * with g_file_unmount_mountable_with_operation(). 2977 * 2978 * Params: 2979 * result = a #GAsyncResult 2980 * 2981 * Returns: %TRUE if the operation finished successfully. 2982 * %FALSE otherwise. 2983 * 2984 * Since: 2.22 2985 * 2986 * Throws: GException on failure. 2987 */ 2988 public bool unmountMountableWithOperationFinish(AsyncResultIF result); 2989 }